[PATCH] D37428: Debug info: Fixed faulty debug locations for attributed statements

2017-09-05 Thread Karl-Johan Karlsson via Phabricator via cfe-commits
Ka-Ka added inline comments.



Comment at: test/CodeGen/debug-info-attributed-stmt.c:1
+// RUN: %clang_cc1 -triple x86_64-unk-unk -disable-llvm-passes 
-debug-info-kind=limited -emit-llvm %s -o - | FileCheck %s
+

echristo wrote:
> Since we're not optimizing or generating code you should be able to remove 
> the -disable-llvm-passes I believe.
I added the option -disable-llvm-passes as David Blaikie suggested it in his 
original comment:
http://lists.llvm.org/pipermail/cfe-commits/Week-of-Mon-20170904/202982.html
As I have mainly worked in llvm backends I'm not that familiar with the clang 
-cc1 options. I have no opinion about this. I wait for you and David Blaikie to 
decide if I should remove or keep the option -disable-llvm-passes.



https://reviews.llvm.org/D37428



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


r312618 - Driver: delete some dead code (NFC)

2017-09-05 Thread Saleem Abdulrasool via cfe-commits
Author: compnerd
Date: Tue Sep  5 22:11:19 2017
New Revision: 312618

URL: http://llvm.org/viewvc/llvm-project?rev=312618=rev
Log:
Driver: delete some dead code (NFC)

This code has been `#if 0`'ed out for a very long time.  After speaking
with Duncan, opt to remove it even if it is something which should be
fixed.  If the underlying issue is still valid, this can be restored
with proper explanation and tests.

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

Modified: cfe/trunk/lib/Driver/ToolChains/Clang.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Clang.cpp?rev=312618=312617=312618=diff
==
--- cfe/trunk/lib/Driver/ToolChains/Clang.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/Clang.cpp Tue Sep  5 22:11:19 2017
@@ -2455,19 +2455,6 @@ static void RenderBuiltinOptions(const T
   // by default.
   if (TC.getArch() == llvm::Triple::le32)
 CmdArgs.push_back("-fno-math-builtin");
-
-#if 0
-  // Default to -fno-builtin-str{cat,cpy} on Darwin for ARM.
-  //
-  // FIXME: Now that PR4941 has been fixed this can be enabled.
-  if (T.isOSDarwin() && (TC.getArch() == llvm::Triple::arm ||
- TC.getArch() == llvm::Triple::thumb)) {
-if (!Args.hasArg(options::OPT_fbuiltin_strcat))
-  CmdArgs.push_back("-fno-builtin-strcat");
-if (!Args.hasArg(options::OPT_fbuiltin_strcpy))
-  CmdArgs.push_back("-fno-builtin-strcpy");
-  }
-#endif
 }
 
 static void RenderModulesOptions(Compilation , const Driver ,


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


[PATCH] D37468: [libc++] Redirect strftime_l to the locale-ignorant strftime on mingw

2017-09-05 Thread Martin Storsjö via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL312617: Redirect strftime_l to the locale-ignorant strftime 
on mingw (authored by mstorsjo).

Changed prior to commit:
  https://reviews.llvm.org/D37468?vs=113838=113956#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D37468

Files:
  libcxx/trunk/include/support/win32/locale_win32.h


Index: libcxx/trunk/include/support/win32/locale_win32.h
===
--- libcxx/trunk/include/support/win32/locale_win32.h
+++ libcxx/trunk/include/support/win32/locale_win32.h
@@ -100,7 +100,11 @@
 #define iswxdigit_l _iswxdigit_l
 #define towupper_l _towupper_l
 #define towlower_l _towlower_l
+#if defined(__MINGW32__) && __MSVCRT_VERSION__ < 0x0800
+#define strftime_l( __s, __l, __f, __tm, __loc ) strftime( __s, __l, __f, __tm 
)
+#else
 #define strftime_l _strftime_l
+#endif
 #define sscanf_l( __s, __l, __f, ...) _sscanf_l( __s, __f, __l, __VA_ARGS__ )
 #define vsscanf_l( __s, __l, __f, ...) _sscanf_l( __s, __f, __l, __VA_ARGS__ )
 #define sprintf_l( __s, __l, __f, ... ) _sprintf_l( __s, __f, __l, __VA_ARGS__ 
)


Index: libcxx/trunk/include/support/win32/locale_win32.h
===
--- libcxx/trunk/include/support/win32/locale_win32.h
+++ libcxx/trunk/include/support/win32/locale_win32.h
@@ -100,7 +100,11 @@
 #define iswxdigit_l _iswxdigit_l
 #define towupper_l _towupper_l
 #define towlower_l _towlower_l
+#if defined(__MINGW32__) && __MSVCRT_VERSION__ < 0x0800
+#define strftime_l( __s, __l, __f, __tm, __loc ) strftime( __s, __l, __f, __tm )
+#else
 #define strftime_l _strftime_l
+#endif
 #define sscanf_l( __s, __l, __f, ...) _sscanf_l( __s, __f, __l, __VA_ARGS__ )
 #define vsscanf_l( __s, __l, __f, ...) _sscanf_l( __s, __f, __l, __VA_ARGS__ )
 #define sprintf_l( __s, __l, __f, ... ) _sprintf_l( __s, __f, __l, __VA_ARGS__ )
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[libcxx] r312617 - Redirect strftime_l to the locale-ignorant strftime on mingw

2017-09-05 Thread Martin Storsjo via cfe-commits
Author: mstorsjo
Date: Tue Sep  5 22:07:25 2017
New Revision: 312617

URL: http://llvm.org/viewvc/llvm-project?rev=312617=rev
Log:
Redirect strftime_l to the locale-ignorant strftime on mingw

_strftime_l is only available in the numbered msvcrt versions
(starting from msvcr80.dll). In the default configuration, mingw
targets the unversioned msvcrt.dll - and there, _strftime_l is
not available (not even on windows 10).

If __MSVCRT_VERSION__ is set to a higher value (indicating a
non-default target and wanting to link to msvcrXX.dll), use the
correct function.

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

Modified:
libcxx/trunk/include/support/win32/locale_win32.h

Modified: libcxx/trunk/include/support/win32/locale_win32.h
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/support/win32/locale_win32.h?rev=312617=312616=312617=diff
==
--- libcxx/trunk/include/support/win32/locale_win32.h (original)
+++ libcxx/trunk/include/support/win32/locale_win32.h Tue Sep  5 22:07:25 2017
@@ -100,7 +100,11 @@ isupper_l(int c, _locale_t loc)
 #define iswxdigit_l _iswxdigit_l
 #define towupper_l _towupper_l
 #define towlower_l _towlower_l
+#if defined(__MINGW32__) && __MSVCRT_VERSION__ < 0x0800
+#define strftime_l( __s, __l, __f, __tm, __loc ) strftime( __s, __l, __f, __tm 
)
+#else
 #define strftime_l _strftime_l
+#endif
 #define sscanf_l( __s, __l, __f, ...) _sscanf_l( __s, __f, __l, __VA_ARGS__ )
 #define vsscanf_l( __s, __l, __f, ...) _sscanf_l( __s, __f, __l, __VA_ARGS__ )
 #define sprintf_l( __s, __l, __f, ... ) _sprintf_l( __s, __f, __l, __VA_ARGS__ 
)


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


r312616 - Driver: remove unused variable (NFC)

2017-09-05 Thread Saleem Abdulrasool via cfe-commits
Author: compnerd
Date: Tue Sep  5 21:56:23 2017
New Revision: 312616

URL: http://llvm.org/viewvc/llvm-project?rev=312616=rev
Log:
Driver: remove unused variable (NFC)

Remove `IsHosted` which is no longer needed in `RenderSSPOptions` after
SVN r312595.  The single use can now be inlined.  NFC

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

Modified: cfe/trunk/lib/Driver/ToolChains/Clang.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Clang.cpp?rev=312616=312615=312616=diff
==
--- cfe/trunk/lib/Driver/ToolChains/Clang.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/Clang.cpp Tue Sep  5 21:56:23 2017
@@ -2276,8 +2276,7 @@ static void RenderAnalyzerOptions(const
 }
 
 static void RenderSSPOptions(const ToolChain , const ArgList ,
- ArgStringList , bool KernelOrKext,
- bool IsHosted) {
+ ArgStringList , bool KernelOrKext) {
   const llvm::Triple  = TC.getEffectiveTriple();
 
   // NVPTX doesn't support stack protectors; from the compiler's perspective, 
it
@@ -3803,10 +3802,8 @@ void Clang::ConstructJob(Compilation ,
   Args.AddLastArg(CmdArgs, options::OPT_ftlsmodel_EQ);
 
   // -fhosted is default.
-  bool IsHosted =
-  !Args.hasFlag(options::OPT_ffreestanding, options::OPT_fhosted, false) &&
-  !KernelOrKext;
-  if (!IsHosted)
+  if (Args.hasFlag(options::OPT_ffreestanding, options::OPT_fhosted, false) ||
+  KernelOrKext)
 CmdArgs.push_back("-ffreestanding");
 
   // Forward -f (flag) options which we can pass directly.
@@ -3914,7 +3911,7 @@ void Clang::ConstructJob(Compilation ,
 
   Args.AddLastArg(CmdArgs, options::OPT_pthread);
 
-  RenderSSPOptions(getToolChain(), Args, CmdArgs, KernelOrKext, IsHosted);
+  RenderSSPOptions(getToolChain(), Args, CmdArgs, KernelOrKext);
 
   // Translate -mstackrealign
   if (Args.hasFlag(options::OPT_mstackrealign, options::OPT_mno_stackrealign,


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


[libcxxabi] r312609 - Revert "[libcxxabi] When built with ASan, __cxa_throw calls __asan_handle_no_return"

2017-09-05 Thread Petr Hosek via cfe-commits
Author: phosek
Date: Tue Sep  5 20:00:42 2017
New Revision: 312609

URL: http://llvm.org/viewvc/llvm-project?rev=312609=rev
Log:
Revert "[libcxxabi] When built with ASan, __cxa_throw calls 
__asan_handle_no_return"

This reverts commit r312606 because it's causing an error on
libcxx-libcxxabi-x86_64-linux-ubuntu-asan bot.

Modified:
libcxxabi/trunk/src/cxa_exception.cpp

Modified: libcxxabi/trunk/src/cxa_exception.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxxabi/trunk/src/cxa_exception.cpp?rev=312609=312608=312609=diff
==
--- libcxxabi/trunk/src/cxa_exception.cpp (original)
+++ libcxxabi/trunk/src/cxa_exception.cpp Tue Sep  5 20:00:42 2017
@@ -19,10 +19,6 @@
 #include "cxa_handlers.hpp"
 #include "fallback_malloc.h"
 
-#if __has_feature(address_sanitizer)
-#include 
-#endif
-
 // +---+-+---+
 // | __cxa_exception   | _Unwind_Exception CLNGC++\0 | thrown object |
 // +---+-+---+
@@ -221,12 +217,6 @@ __cxa_throw(void *thrown_object, std::ty
 globals->uncaughtExceptions += 1;   // Not atomically, since globals are 
thread-local
 
 exception_header->unwindHeader.exception_cleanup = exception_cleanup_func;
-
-#if __has_feature(address_sanitizer)
-// Inform the ASan runtime that now might be a good time to clean stuff up.
-__asan_handle_no_return();
-#endif
-
 #ifdef __USING_SJLJ_EXCEPTIONS__
 _Unwind_SjLj_RaiseException(_header->unwindHeader);
 #else


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


[libcxxabi] r312606 - [libcxxabi] When built with ASan, __cxa_throw calls __asan_handle_no_return

2017-09-05 Thread Petr Hosek via cfe-commits
Author: phosek
Date: Tue Sep  5 19:43:54 2017
New Revision: 312606

URL: http://llvm.org/viewvc/llvm-project?rev=312606=rev
Log:
[libcxxabi] When built with ASan, __cxa_throw calls __asan_handle_no_return

The ASan runtime on many systems intercepts cxa_throw just so it
can call asan_handle_no_return first. Some newer systems such as
Fuchsia don't use interceptors on standard library functions at all,
but instead use sanitizer-instrumented versions of the standard
libraries. When libc++abi is built with ASan, cxa_throw can just
call asan_handle_no_return itself so no interceptor is required.

This is a re-land of r311045, which has become safe after r311869
changed compiler-rt to declare __asan_handle_no_return.

Patch by Roland McGrath

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

Modified:
libcxxabi/trunk/src/cxa_exception.cpp

Modified: libcxxabi/trunk/src/cxa_exception.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxxabi/trunk/src/cxa_exception.cpp?rev=312606=312605=312606=diff
==
--- libcxxabi/trunk/src/cxa_exception.cpp (original)
+++ libcxxabi/trunk/src/cxa_exception.cpp Tue Sep  5 19:43:54 2017
@@ -19,6 +19,10 @@
 #include "cxa_handlers.hpp"
 #include "fallback_malloc.h"
 
+#if __has_feature(address_sanitizer)
+#include 
+#endif
+
 // +---+-+---+
 // | __cxa_exception   | _Unwind_Exception CLNGC++\0 | thrown object |
 // +---+-+---+
@@ -217,6 +221,12 @@ __cxa_throw(void *thrown_object, std::ty
 globals->uncaughtExceptions += 1;   // Not atomically, since globals are 
thread-local
 
 exception_header->unwindHeader.exception_cleanup = exception_cleanup_func;
+
+#if __has_feature(address_sanitizer)
+// Inform the ASan runtime that now might be a good time to clean stuff up.
+__asan_handle_no_return();
+#endif
+
 #ifdef __USING_SJLJ_EXCEPTIONS__
 _Unwind_SjLj_RaiseException(_header->unwindHeader);
 #else


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


[PATCH] D37496: Fix validation of the -mthread-model flag in the Clang driver

2017-09-05 Thread Saleem Abdulrasool via Phabricator via cfe-commits
compnerd added a comment.

The change looks good.  Can you please add some test cases for this?  Or do 
existing test cases cover this already?


https://reviews.llvm.org/D37496



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


Re: r312595 - [Darwin] Enable -fstack-protector (back) by default with -ffreestanding

2017-09-05 Thread Bruno Cardoso Lopes via cfe-commits
On Tue, Sep 5, 2017 at 4:58 PM, Joerg Sonnenberger via cfe-commits
 wrote:
> On Tue, Sep 05, 2017 at 11:50:58PM -, Bruno Cardoso Lopes via cfe-commits 
> wrote:
>> Modified: cfe/trunk/lib/Driver/ToolChains/Clang.cpp
>> URL: 
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Clang.cpp?rev=312595=312594=312595=diff
>> ==
>> --- cfe/trunk/lib/Driver/ToolChains/Clang.cpp (original)
>> +++ cfe/trunk/lib/Driver/ToolChains/Clang.cpp Tue Sep  5 16:50:58 2017
>> @@ -2302,11 +2302,6 @@ static void RenderSSPOptions(const ToolC
>>  else if (A->getOption().matches(options::OPT_fstack_protector_all))
>>StackProtectorLevel = LangOptions::SSPReq;
>>} else {
>> -// Only use a default stack protector on Darwin in case -ffreestanding 
>> is
>> -// not specified.
>> -if (EffectiveTriple.isOSDarwin() && !IsHosted)
>> -  StackProtectorLevel = 0;
>> -else
>>StackProtectorLevel = DefaultStackProtectorLevel;
>>}
>
> Indentation?

Thanks for the catch, done in r312599

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



-- 
Bruno Cardoso Lopes
http://www.brunocardoso.cc
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r312599 - Fix indentation mistake from r312595

2017-09-05 Thread Bruno Cardoso Lopes via cfe-commits
Author: bruno
Date: Tue Sep  5 17:44:10 2017
New Revision: 312599

URL: http://llvm.org/viewvc/llvm-project?rev=312599=rev
Log:
Fix indentation mistake from r312595

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

Modified: cfe/trunk/lib/Driver/ToolChains/Clang.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Clang.cpp?rev=312599=312598=312599=diff
==
--- cfe/trunk/lib/Driver/ToolChains/Clang.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/Clang.cpp Tue Sep  5 17:44:10 2017
@@ -2302,7 +2302,7 @@ static void RenderSSPOptions(const ToolC
 else if (A->getOption().matches(options::OPT_fstack_protector_all))
   StackProtectorLevel = LangOptions::SSPReq;
   } else {
-  StackProtectorLevel = DefaultStackProtectorLevel;
+StackProtectorLevel = DefaultStackProtectorLevel;
   }
 
   if (StackProtectorLevel) {


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


[PATCH] D35082: [OpenCL] Add LangAS::opencl_private to represent private address space in AST

2017-09-05 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl marked an inline comment as done.
yaxunl added a comment.

ping


https://reviews.llvm.org/D35082



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


Re: r312595 - [Darwin] Enable -fstack-protector (back) by default with -ffreestanding

2017-09-05 Thread Joerg Sonnenberger via cfe-commits
On Tue, Sep 05, 2017 at 11:50:58PM -, Bruno Cardoso Lopes via cfe-commits 
wrote:
> Modified: cfe/trunk/lib/Driver/ToolChains/Clang.cpp
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Clang.cpp?rev=312595=312594=312595=diff
> ==
> --- cfe/trunk/lib/Driver/ToolChains/Clang.cpp (original)
> +++ cfe/trunk/lib/Driver/ToolChains/Clang.cpp Tue Sep  5 16:50:58 2017
> @@ -2302,11 +2302,6 @@ static void RenderSSPOptions(const ToolC
>  else if (A->getOption().matches(options::OPT_fstack_protector_all))
>StackProtectorLevel = LangOptions::SSPReq;
>} else {
> -// Only use a default stack protector on Darwin in case -ffreestanding is
> -// not specified.
> -if (EffectiveTriple.isOSDarwin() && !IsHosted)
> -  StackProtectorLevel = 0;
> -else
>StackProtectorLevel = DefaultStackProtectorLevel;
>}

Indentation?

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


r312595 - [Darwin] Enable -fstack-protector (back) by default with -ffreestanding

2017-09-05 Thread Bruno Cardoso Lopes via cfe-commits
Author: bruno
Date: Tue Sep  5 16:50:58 2017
New Revision: 312595

URL: http://llvm.org/viewvc/llvm-project?rev=312595=rev
Log:
[Darwin] Enable -fstack-protector (back) by default with -ffreestanding

Go back to behavior prior to r289005.

rdar://problem/32987198

Modified:
cfe/trunk/lib/Driver/ToolChains/Clang.cpp
cfe/trunk/test/Driver/stack-protector.c

Modified: cfe/trunk/lib/Driver/ToolChains/Clang.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Clang.cpp?rev=312595=312594=312595=diff
==
--- cfe/trunk/lib/Driver/ToolChains/Clang.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/Clang.cpp Tue Sep  5 16:50:58 2017
@@ -2302,11 +2302,6 @@ static void RenderSSPOptions(const ToolC
 else if (A->getOption().matches(options::OPT_fstack_protector_all))
   StackProtectorLevel = LangOptions::SSPReq;
   } else {
-// Only use a default stack protector on Darwin in case -ffreestanding is
-// not specified.
-if (EffectiveTriple.isOSDarwin() && !IsHosted)
-  StackProtectorLevel = 0;
-else
   StackProtectorLevel = DefaultStackProtectorLevel;
   }
 

Modified: cfe/trunk/test/Driver/stack-protector.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/stack-protector.c?rev=312595=312594=312595=diff
==
--- cfe/trunk/test/Driver/stack-protector.c (original)
+++ cfe/trunk/test/Driver/stack-protector.c Tue Sep  5 16:50:58 2017
@@ -36,27 +36,20 @@
 // Test default stack protector values for Darwin platforms
 
 // RUN: %clang -target armv7k-apple-watchos2.0 -### %s 2>&1 | FileCheck %s 
-check-prefix=SSP_WATCHOS
+// RUN: %clang -ffreestanding -target armv7k-apple-watchos2.0 -### %s 2>&1 | 
FileCheck %s -check-prefix=SSP_WATCHOS
 // SSP_WATCHOS: "-stack-protector" "1"
 // RUN: %clang -target arm64-apple-ios8.0.0 -### %s 2>&1 | FileCheck %s 
-check-prefix=SSP_IOS
+// RUN: %clang -ffreestanding -target arm64-apple-ios8.0.0 -### %s 2>&1 | 
FileCheck %s -check-prefix=SSP_IOS
 // SSP_IOS: "-stack-protector" "1"
 // RUN: %clang -target x86_64-apple-darwin10 -mmacosx-version-min=10.6 -### %s 
2>&1 | FileCheck %s -check-prefix=SSP_MACOSX
+// RUN: %clang -ffreestanding -target x86_64-apple-darwin10 
-mmacosx-version-min=10.6 -### %s 2>&1 | FileCheck %s -check-prefix=SSP_MACOSX
 // SSP_MACOSX: "-stack-protector" "1"
 // RUN: %clang -target x86_64-apple-darwin10 -mmacosx-version-min=10.5 -### %s 
2>&1 | FileCheck %s -check-prefix=SSP_MACOSX_10_5
+// RUN: %clang -ffreestanding -target x86_64-apple-darwin10 
-mmacosx-version-min=10.5 -### %s 2>&1 | FileCheck %s 
-check-prefix=SSP_MACOSX_10_5
 // SSP_MACOSX_10_5: "-stack-protector" "1"
 // RUN: %clang -target x86_64-apple-darwin10 -mmacosx-version-min=10.5 
-mkernel -### %s 2>&1 | FileCheck %s -check-prefix=SSP_MACOSX_KERNEL
 // SSP_MACOSX_KERNEL-NOT: "-stack-protector"
 // RUN: %clang -target x86_64-apple-darwin10 -mmacosx-version-min=10.6 -### %s 
2>&1 | FileCheck %s -check-prefix=SSP_MACOSX_10_6_KERNEL
+// RUN: %clang -ffreestanding -target x86_64-apple-darwin10 
-mmacosx-version-min=10.6 -### %s 2>&1 | FileCheck %s 
-check-prefix=SSP_MACOSX_10_6_KERNEL
 // SSP_MACOSX_10_6_KERNEL: "-stack-protector" "1"
 
-// Test default stack protector values for Darwin platforms with -ffreestanding
-
-// RUN: %clang -ffreestanding -target armv7k-apple-watchos2.0 -### %s 2>&1 | 
FileCheck %s -check-prefix=SSP_FREE_WATCHOS
-// SSP_FREE_WATCHOS-NOT: "-stack-protector"
-// RUN: %clang -ffreestanding -target arm64-apple-ios8.0.0 -### %s 2>&1 | 
FileCheck %s -check-prefix=SSP_FREE_IOS
-// SSP_FREE_IOS-NOT: "-stack-protector"
-// RUN: %clang -ffreestanding -target x86_64-apple-darwin10 
-mmacosx-version-min=10.6 -### %s 2>&1 | FileCheck %s 
-check-prefix=SSP_FREE_MACOSX
-// SSP_FREE_MACOSX-NOT: "-stack-protector"
-// RUN: %clang -ffreestanding -target x86_64-apple-darwin10 
-mmacosx-version-min=10.5 -### %s 2>&1 | FileCheck %s 
-check-prefix=SSP_FREE_MACOSX_10_5
-// SSP_FREE_MACOSX_10_5-NOT: "-stack-protector"
-// RUN: %clang -ffreestanding -target x86_64-apple-darwin10 
-mmacosx-version-min=10.6 -### %s 2>&1 | FileCheck %s 
-check-prefix=SSP_FREE_MACOSX_10_6_KERNEL
-// SSP_FREE_MACOSX_10_6_KERNEL-NOT: "-stack-protector"


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


[PATCH] D37493: Fix ARM bare metal driver to support atomics

2017-09-05 Thread Ian Tessier via Phabricator via cfe-commits
itessier added a comment.

I don't have SVN access, can somebody commit this change for me?


https://reviews.llvm.org/D37493



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


[PATCH] D37496: Fix validation of the -mthread-model flag in the Clang driver

2017-09-05 Thread Ian Tessier via Phabricator via cfe-commits
itessier created this revision.

The ToolChain class validates the -mthread-model flag in the constructor which 
doesn't work correctly since the thread model methods are virtual methods. The 
check is moved into Clang::ConstructJob() when constructing the internal 
command line.


https://reviews.llvm.org/D37496

Files:
  lib/Driver/ToolChain.cpp
  lib/Driver/ToolChains/Clang.cpp


Index: lib/Driver/ToolChains/Clang.cpp
===
--- lib/Driver/ToolChains/Clang.cpp
+++ lib/Driver/ToolChains/Clang.cpp
@@ -3254,8 +3254,12 @@
   }
 
   CmdArgs.push_back("-mthread-model");
-  if (Arg *A = Args.getLastArg(options::OPT_mthread_model))
+  if (Arg *A = Args.getLastArg(options::OPT_mthread_model)) {
+if (!getToolChain().isThreadModelSupported(A->getValue()))
+  D.Diag(diag::err_drv_invalid_thread_model_for_target)
+  << A->getValue() << A->getAsString(Args);
 CmdArgs.push_back(A->getValue());
+  }
   else
 CmdArgs.push_back(Args.MakeArgString(getToolChain().getThreadModel()));
 
Index: lib/Driver/ToolChain.cpp
===
--- lib/Driver/ToolChain.cpp
+++ lib/Driver/ToolChain.cpp
@@ -74,11 +74,6 @@
 : D(D), Triple(T), Args(Args), CachedRTTIArg(GetRTTIArgument(Args)),
   CachedRTTIMode(CalculateRTTIMode(Args, Triple, CachedRTTIArg)),
   EffectiveTriple() {
-  if (Arg *A = Args.getLastArg(options::OPT_mthread_model))
-if (!isThreadModelSupported(A->getValue()))
-  D.Diag(diag::err_drv_invalid_thread_model_for_target)
-  << A->getValue() << A->getAsString(Args);
-
   std::string CandidateLibPath = getArchSpecificLibPath();
   if (getVFS().exists(CandidateLibPath))
 getFilePaths().push_back(CandidateLibPath);


Index: lib/Driver/ToolChains/Clang.cpp
===
--- lib/Driver/ToolChains/Clang.cpp
+++ lib/Driver/ToolChains/Clang.cpp
@@ -3254,8 +3254,12 @@
   }
 
   CmdArgs.push_back("-mthread-model");
-  if (Arg *A = Args.getLastArg(options::OPT_mthread_model))
+  if (Arg *A = Args.getLastArg(options::OPT_mthread_model)) {
+if (!getToolChain().isThreadModelSupported(A->getValue()))
+  D.Diag(diag::err_drv_invalid_thread_model_for_target)
+  << A->getValue() << A->getAsString(Args);
 CmdArgs.push_back(A->getValue());
+  }
   else
 CmdArgs.push_back(Args.MakeArgString(getToolChain().getThreadModel()));
 
Index: lib/Driver/ToolChain.cpp
===
--- lib/Driver/ToolChain.cpp
+++ lib/Driver/ToolChain.cpp
@@ -74,11 +74,6 @@
 : D(D), Triple(T), Args(Args), CachedRTTIArg(GetRTTIArgument(Args)),
   CachedRTTIMode(CalculateRTTIMode(Args, Triple, CachedRTTIArg)),
   EffectiveTriple() {
-  if (Arg *A = Args.getLastArg(options::OPT_mthread_model))
-if (!isThreadModelSupported(A->getValue()))
-  D.Diag(diag::err_drv_invalid_thread_model_for_target)
-  << A->getValue() << A->getAsString(Args);
-
   std::string CandidateLibPath = getArchSpecificLibPath();
   if (getVFS().exists(CandidateLibPath))
 getFilePaths().push_back(CandidateLibPath);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D37479: run-clang-tidy: Report progress

2017-09-05 Thread Eugene Zelenko via Phabricator via cfe-commits
Eugene.Zelenko added a comment.

It'll be also nice to output progress in terminal when all messages will saved 
into file.


https://reviews.llvm.org/D37479



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


[PATCH] D37468: [libc++] Redirect strftime_l to the locale-ignorant strftime on mingw

2017-09-05 Thread Saleem Abdulrasool via Phabricator via cfe-commits
compnerd accepted this revision.
compnerd added a comment.
This revision is now accepted and ready to land.

ick


https://reviews.llvm.org/D37468



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


[PATCH] D37479: run-clang-tidy: Report progress

2017-09-05 Thread Kevin Funk via Phabricator via cfe-commits
kfunk added a comment.

In https://reviews.llvm.org/D37479#861580, @Eugene.Zelenko wrote:

> I think will be good idea to introduce command line option to control 
> progress display: turn it off, show in absolute numbers or percents.


Honestly, I don't think this configurability is necessary. I'd like to keep 
that script here as simple as possible.

I'll wait for some more opinions.


https://reviews.llvm.org/D37479



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


[PATCH] D37479: run-clang-tidy: Report progress

2017-09-05 Thread Eugene Zelenko via Phabricator via cfe-commits
Eugene.Zelenko added a comment.

I think will be good idea to introduce command line option to control progress 
display: turn it off, show in absolute numbers or percents.


https://reviews.llvm.org/D37479



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


[PATCH] D37428: Debug info: Fixed faulty debug locations for attributed statements

2017-09-05 Thread Eric Christopher via Phabricator via cfe-commits
echristo added inline comments.



Comment at: test/CodeGen/debug-info-attributed-stmt.c:1
+// RUN: %clang_cc1 -triple x86_64-unk-unk -disable-llvm-passes 
-debug-info-kind=limited -emit-llvm %s -o - | FileCheck %s
+

Since we're not optimizing or generating code you should be able to remove the 
-disable-llvm-passes I believe.


https://reviews.llvm.org/D37428



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


Re: r312467 - Implement Itanium name mangling support for C++ Modules TS.

2017-09-05 Thread Richard Smith via cfe-commits
Should be fixed in r312580, thanks!

On 5 September 2017 at 13:58, Richard Smith  wrote:

> Thanks, looking...
>
> On 5 September 2017 at 13:31, Evgenii Stepanov via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
>
>> Hi Richard,
>>
>> this change has triggered a bunch of leak reports on the sanitizer bots:
>>
>> Direct leak of 1824 byte(s) in 1 object(s) allocated from:
>> #0 0xb48430 in operator new(unsigned long)
>> /mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build
>> /llvm/projects/compiler-rt/lib/asan/asan_new_delete.cc:82
>> #1 0xadfd119 in
>> clang::ModuleMap::createGlobalModuleForInterfaceUnit(clang::
>> SourceLocation)
>> /mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build
>> /llvm/tools/clang/lib/Lex/ModuleMap.cpp:750:18
>> #2 0x860e9be in clang::Sema::ActOnStartOfTranslationUnit()
>> /mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build
>> /llvm/tools/clang/lib/Sema/Sema.cpp:775:30
>> #3 0x7d27209 in
>> clang::Parser::ParseFirstTopLevelDecl(clang::OpaquePtr<
>> clang::DeclGroupRef>&)
>> /mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build
>> /llvm/tools/clang/lib/Parse/Parser.cpp:529:11
>> #4 0x7d158fe in clang::ParseAST(clang::Sema&, bool, bool)
>> /mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build
>> /llvm/tools/clang/lib/Parse/ParseAST.cpp:146:23
>> #5 0x618926e in clang::FrontendAction::Execute()
>> /mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build
>> /llvm/tools/clang/lib/Frontend/FrontendAction.cpp:902:8
>> #6 0x6090664 in
>> clang::CompilerInstance::ExecuteAction(clang::FrontendAction&)
>> /mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build
>> /llvm/tools/clang/lib/Frontend/CompilerInstance.cpp:986:11
>> #7 0x637eb45 in
>> clang::ExecuteCompilerInvocation(clang::CompilerInstance*)
>> /mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build
>> /llvm/tools/clang/lib/FrontendTool/ExecuteCompilerInvocation.cpp:252:25
>> #8 0xb5b13f in cc1_main(llvm::ArrayRef, char const*,
>> void*) /mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build
>> /llvm/tools/clang/tools/driver/cc1_main.cpp:221:13
>> #9 0xb53d33 in ExecuteCC1Tool
>> /mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build
>> /llvm/tools/clang/tools/driver/driver.cpp:302:12
>> #10 0xb53d33 in main
>> /mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build
>> /llvm/tools/clang/tools/driver/driver.cpp:381
>> #11 0x7fc921b0b82f in __libc_start_main
>> (/lib/x86_64-linux-gnu/libc.so.6+0x2082f)
>>
>> Failing Tests (16):
>> Clang :: CXX/modules-ts/basic/basic.def.odr/p4/module.cpp
>> Clang :: CXX/modules-ts/basic/basic.def.odr/p4/user.cpp
>> Clang :: CXX/modules-ts/basic/basic.link/module-declaration.cpp
>> Clang :: CXX/modules-ts/basic/basic.link/p2/module.cpp
>> Clang :: CXX/modules-ts/basic/basic.link/p2/other.cpp
>> Clang :: CXX/modules-ts/basic/basic.search/module-import.cpp
>> Clang :: CXX/modules-ts/codegen-basics.cppm
>> Clang :: CXX/modules-ts/dcl.dcl/dcl.module/dcl.module.import/p1.cpp
>> Clang :: CXX/modules-ts/dcl.dcl/dcl.module/dcl.module.interface/p1.
>> cpp
>> Clang :: CXX/modules-ts/dcl.dcl/dcl.module/p5.cpp
>> Clang :: Driver/modules-ts.cpp
>> Clang :: Lexer/modules-ts.cpp
>> Clang :: Modules/diag-flags.cpp
>> Clang :: Modules/diag-pragma.cpp
>> Clang :: Modules/import-syntax.c
>> Clang :: SemaCXX/modules-ts.cppm
>>
>> http://lab.llvm.org:8011/builders/sanitizer-x86_64-linux-fast/builds/7630
>>
>> On Sun, Sep 3, 2017 at 10:37 PM, Richard Smith via cfe-commits
>>  wrote:
>> > Author: rsmith
>> > Date: Sun Sep  3 22:37:53 2017
>> > New Revision: 312467
>> >
>> > URL: http://llvm.org/viewvc/llvm-project?rev=312467=rev
>> > Log:
>> > Implement Itanium name mangling support for C++ Modules TS.
>> >
>> > This follows the scheme agreed with Nathan Sidwell, which can be found
>> here:
>> >
>> >   https://gcc.gnu.org/wiki/cxx-modules?action=AttachFile
>> >
>> > This will be proposed to the itanium-cxx-abi list once we have some
>> experience
>> > with how well it works; the ABI for this TS should be considered
>> unstable until
>> > it is part of the Itanium C++ ABI.
>> >
>> > Modified:
>> > cfe/trunk/include/clang/AST/Decl.h
>> > cfe/trunk/include/clang/AST/DeclBase.h
>> > cfe/trunk/include/clang/Basic/Module.h
>> > cfe/trunk/include/clang/Lex/ModuleMap.h
>> > cfe/trunk/lib/AST/Decl.cpp
>> > cfe/trunk/lib/AST/ItaniumMangle.cpp
>> > cfe/trunk/lib/Lex/ModuleMap.cpp
>> > cfe/trunk/lib/Sema/Sema.cpp
>> > cfe/trunk/lib/Sema/SemaDecl.cpp
>> > cfe/trunk/lib/Serialization/ASTReader.cpp
>> > cfe/trunk/lib/Serialization/ASTWriter.cpp
>> > cfe/trunk/test/CXX/modules-ts/basic/basic.def.odr/p4/module.cpp
>> > cfe/trunk/test/CXX/modules-ts/basic/basic.def.odr/p4/module.cppm
>> > cfe/trunk/test/CXX/modules-ts/basic/basic.def.odr/p4/user.cpp
>> > 

r312580 - Fix memory leak after r312467. The ModuleMap is the owner of the global module object until it's reparented under a real module.

2017-09-05 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Tue Sep  5 14:46:22 2017
New Revision: 312580

URL: http://llvm.org/viewvc/llvm-project?rev=312580=rev
Log:
Fix memory leak after r312467. The ModuleMap is the owner of the global module 
object until it's reparented under a real module.

Modified:
cfe/trunk/include/clang/Lex/ModuleMap.h
cfe/trunk/lib/Lex/ModuleMap.cpp

Modified: cfe/trunk/include/clang/Lex/ModuleMap.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Lex/ModuleMap.h?rev=312580=312579=312580=diff
==
--- cfe/trunk/include/clang/Lex/ModuleMap.h (original)
+++ cfe/trunk/include/clang/Lex/ModuleMap.h Tue Sep  5 14:46:22 2017
@@ -82,22 +82,26 @@ class ModuleMap {
   
   /// \brief The directory used for Clang-supplied, builtin include headers,
   /// such as "stdint.h".
-  const DirectoryEntry *BuiltinIncludeDir;
+  const DirectoryEntry *BuiltinIncludeDir = nullptr;
   
   /// \brief Language options used to parse the module map itself.
   ///
   /// These are always simple C language options.
   LangOptions MMapLangOpts;
 
-  // The module that the main source file is associated with (the module
-  // named LangOpts::CurrentModule, if we've loaded it).
-  Module *SourceModule;
+  /// The module that the main source file is associated with (the module
+  /// named LangOpts::CurrentModule, if we've loaded it).
+  Module *SourceModule = nullptr;
+
+  /// The global module for the current TU, if we still own it. (Ownership is
+  /// transferred if/when we create an enclosing module.
+  std::unique_ptr PendingGlobalModule;
 
   /// \brief The top-level modules that are known.
   llvm::StringMap Modules;
 
   /// \brief The number of modules we have created in total.
-  unsigned NumCreatedModules;
+  unsigned NumCreatedModules = 0;
 
 public:
   /// \brief Flags describing the role of a module header.

Modified: cfe/trunk/lib/Lex/ModuleMap.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/ModuleMap.cpp?rev=312580=312579=312580=diff
==
--- cfe/trunk/lib/Lex/ModuleMap.cpp (original)
+++ cfe/trunk/lib/Lex/ModuleMap.cpp Tue Sep  5 14:46:22 2017
@@ -256,8 +256,7 @@ ModuleMap::ModuleMap(SourceManager 
  const LangOptions , const TargetInfo *Target,
  HeaderSearch )
 : SourceMgr(SourceMgr), Diags(Diags), LangOpts(LangOpts), Target(Target),
-  HeaderInfo(HeaderInfo), BuiltinIncludeDir(nullptr),
-  SourceModule(nullptr), NumCreatedModules(0) {
+  HeaderInfo(HeaderInfo) {
   MMapLangOpts.LineComment = true;
 }
 
@@ -747,10 +746,12 @@ std::pair ModuleMap::fin
 }
 
 Module *ModuleMap::createGlobalModuleForInterfaceUnit(SourceLocation Loc) {
-  auto *Result = new Module("", Loc, nullptr, /*IsFramework*/ false,
-/*IsExplicit*/ true, NumCreatedModules++);
-  Result->Kind = Module::GlobalModuleFragment;
-  return Result;
+  assert(!PendingGlobalModule && "created multiple global modules");
+  PendingGlobalModule.reset(
+  new Module("", Loc, nullptr, /*IsFramework*/ false,
+ /*IsExplicit*/ true, NumCreatedModules++));
+  PendingGlobalModule->Kind = Module::GlobalModuleFragment;
+  return PendingGlobalModule.get();
 }
 
 Module *ModuleMap::createModuleForInterfaceUnit(SourceLocation Loc,
@@ -766,7 +767,10 @@ Module *ModuleMap::createModuleForInterf
   Modules[Name] = SourceModule = Result;
 
   // Reparent the current global module fragment as a submodule of this module.
+  assert(GlobalModule == PendingGlobalModule.get() &&
+ "unexpected global module");
   GlobalModule->setParent(Result);
+  PendingGlobalModule.release(); // now owned by parent
 
   // Mark the main source file as being within the newly-created module so that
   // declarations and macros are properly visibility-restricted to it.


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


[PATCH] D36410: [OpenCL] Handle taking address of block captures

2017-09-05 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl added a comment.

In https://reviews.llvm.org/D36410#856907, @bader wrote:

> In https://reviews.llvm.org/D36410#856716, @yaxunl wrote:
>
> > The captured variable is still passed by value. The address taking is on 
> > the duplicate of the captured variable, not on the original variable.
>
>
> In this case address of captured variables should point to the private 
> address space, as function parameters reside in private address space (see 
> "6.5 Address Space Qualifiers" paragraph 3).
>  This makes unclear to me how capturing works for variables declared in the 
> address spaces other than private (e.g. `local int a;`).


Sorry I was not accurate when saying the captured variables are passed by value.

The captured variable is emitted as a member of the block context structure. 
There are two situations:

1. the block is called as a normal block.

In this case , the block context is in stack and passed indirectly to the block 
invoke function, so taking address of captured variable results in a private 
pointer.

3. the block is called through enqueue_kernel as a kernel.

In this case the address space of block context depends on how the target pass 
the block context to the kernel.

Some target may pass the block context struct directly, in this case taking 
address of captured variable results in a private pointer.

Some target may pass the block context struct by a pointer to global memory, in 
this case taking address of captured variable results in a global pointer.

Unless the target is able to handle indirect byval kernel argument, the block 
invoke function will ends up with different ISA's when called as a normal
block and called as a device-enqueued kernel.

One possible solution may be:

1. when emitting code for the definition of the block, assuming it is a normal 
block and let captured variables have private address space.

2. when emitting code for enqueue_kernel,

  emit a target-specific version of the block invoke function again which uses 
proper kernel ABI and with kernel metadata. Let the captured variables have 
target-specific address space.

However, since this may take some time and efforts to implement, I think the 
current patch is acceptable as a temporary measure.


https://reviews.llvm.org/D36410



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


[PATCH] D33852: Enable __declspec(selectany) on linux

2017-09-05 Thread Piotr Padlewski via Phabricator via cfe-commits
Prazek marked an inline comment as done.
Prazek added inline comments.



Comment at: include/clang/Basic/AttrDocs.td:3154
+
+def SelectAnyDocs : Documentation {
+   let Content = [{This attribute makes global symbol have a weak definition

aaron.ballman wrote:
> Prazek wrote:
> > aaron.ballman wrote:
> > > I think you need to set the `Category` as well.
> > > 
> > > To test this you should run something like (replacing  and fixing 
> > > up path separators as needed):
> > > ```
> > > clang-tblgen -gen-attr-docs -I \llvm\tools\clang\include 
> > > \llvm\tools\clang\include\clang\Basic\Attr.td -o 
> > > \llvm\tools\clang\docs\AttributeReference.rst
> > > ```
> > Thanks for the testing command. Should I do anything in order to check if 
> > docs build?
> > I enabled docs with -DLLVM_BUILD_DOCS=ON, and I have sphinx. Everything 
> > builds, but I don't see docs anywhere.
> > 
> > the docs looks like this:
> > +selectany (gnu::selectany)
> > +--
> > +.. csv-table:: Supported Syntaxes
> > +   :header: "GNU", "C++11", "__declspec", "Keyword", "Pragma", "Pragma 
> > clang attribute"
> > +
> > +   "X","X","X","", "", ""
> > +
> > +This attribute appertains to a global symbol, causing it to have a weak
> > +definition (
> > +.. _`linkonce`: https://llvm.org/docs/LangRef.html#linkage-types
> > +), allowing the linker to select any definition.
> > +
> > +For more information see
> > +.. `gcc documentation`: 
> > https://gcc.gnu.org/onlinedocs/gcc-7.2.0/gcc/Microsoft-Windows-Variable-Attributes.html
> > +
> > Thanks for the testing command. Should I do anything in order to check if 
> > docs build?
> 
> On Windows, I use `make html` within the clang\docs directory to generate the 
> actual sphinx docs -- that will tell you if there are sphinx issues. Be sure 
> you do *not* commit the AttributeReference.rst file that it generates, 
> however.
I tried building docs but it doesn't seem that there is any target like "html". 
Do you know if there is documentation on how to build docs? I couldn't find any.


https://reviews.llvm.org/D33852



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


[PATCH] D37448: Fix cast assertion on MS inline assembly with vector spills (PR34021)

2017-09-05 Thread Erich Keane via Phabricator via cfe-commits
erichkeane added a comment.

In https://reviews.llvm.org/D37448#861443, @efriedma wrote:

> > According to our definition, v4si is NOT a "Vector" type, since a vector 
> > type requires it be a FP value.
>
> Umm, what?  An integer vector is still a vector.  The backend will return it 
> in xmm0 on x86 (both 32 and 64-bit).


Ugg.. you're right.  I missed that addReturnRegisterOutputs was creating a 
return type as an integer, so when it was being checked in this if/else tree 
(edited above) you're not actually looking at the return type anymore


Repository:
  rL LLVM

https://reviews.llvm.org/D37448



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


Re: r312467 - Implement Itanium name mangling support for C++ Modules TS.

2017-09-05 Thread Richard Smith via cfe-commits
Thanks, looking...

On 5 September 2017 at 13:31, Evgenii Stepanov via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Hi Richard,
>
> this change has triggered a bunch of leak reports on the sanitizer bots:
>
> Direct leak of 1824 byte(s) in 1 object(s) allocated from:
> #0 0xb48430 in operator new(unsigned long)
> /mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/
> build/llvm/projects/compiler-rt/lib/asan/asan_new_delete.cc:82
> #1 0xadfd119 in
> clang::ModuleMap::createGlobalModuleForInterface
> Unit(clang::SourceLocation)
> /mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/
> build/llvm/tools/clang/lib/Lex/ModuleMap.cpp:750:18
> #2 0x860e9be in clang::Sema::ActOnStartOfTranslationUnit()
> /mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/
> build/llvm/tools/clang/lib/Sema/Sema.cpp:775:30
> #3 0x7d27209 in
> clang::Parser::ParseFirstTopLevelDecl(clang::
> OpaquePtr&)
> /mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/
> build/llvm/tools/clang/lib/Parse/Parser.cpp:529:11
> #4 0x7d158fe in clang::ParseAST(clang::Sema&, bool, bool)
> /mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/
> build/llvm/tools/clang/lib/Parse/ParseAST.cpp:146:23
> #5 0x618926e in clang::FrontendAction::Execute()
> /mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/
> build/llvm/tools/clang/lib/Frontend/FrontendAction.cpp:902:8
> #6 0x6090664 in
> clang::CompilerInstance::ExecuteAction(clang::FrontendAction&)
> /mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/
> build/llvm/tools/clang/lib/Frontend/CompilerInstance.cpp:986:11
> #7 0x637eb45 in
> clang::ExecuteCompilerInvocation(clang::CompilerInstance*)
> /mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/
> build/llvm/tools/clang/lib/FrontendTool/ExecuteCompilerInvocation.cpp:
> 252:25
> #8 0xb5b13f in cc1_main(llvm::ArrayRef, char const*,
> void*) /mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/
> build/llvm/tools/clang/tools/driver/cc1_main.cpp:221:13
> #9 0xb53d33 in ExecuteCC1Tool
> /mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/
> build/llvm/tools/clang/tools/driver/driver.cpp:302:12
> #10 0xb53d33 in main
> /mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/
> build/llvm/tools/clang/tools/driver/driver.cpp:381
> #11 0x7fc921b0b82f in __libc_start_main
> (/lib/x86_64-linux-gnu/libc.so.6+0x2082f)
>
> Failing Tests (16):
> Clang :: CXX/modules-ts/basic/basic.def.odr/p4/module.cpp
> Clang :: CXX/modules-ts/basic/basic.def.odr/p4/user.cpp
> Clang :: CXX/modules-ts/basic/basic.link/module-declaration.cpp
> Clang :: CXX/modules-ts/basic/basic.link/p2/module.cpp
> Clang :: CXX/modules-ts/basic/basic.link/p2/other.cpp
> Clang :: CXX/modules-ts/basic/basic.search/module-import.cpp
> Clang :: CXX/modules-ts/codegen-basics.cppm
> Clang :: CXX/modules-ts/dcl.dcl/dcl.module/dcl.module.import/p1.cpp
> Clang :: CXX/modules-ts/dcl.dcl/dcl.module/dcl.module.interface/p1.cpp
> Clang :: CXX/modules-ts/dcl.dcl/dcl.module/p5.cpp
> Clang :: Driver/modules-ts.cpp
> Clang :: Lexer/modules-ts.cpp
> Clang :: Modules/diag-flags.cpp
> Clang :: Modules/diag-pragma.cpp
> Clang :: Modules/import-syntax.c
> Clang :: SemaCXX/modules-ts.cppm
>
> http://lab.llvm.org:8011/builders/sanitizer-x86_64-linux-fast/builds/7630
>
> On Sun, Sep 3, 2017 at 10:37 PM, Richard Smith via cfe-commits
>  wrote:
> > Author: rsmith
> > Date: Sun Sep  3 22:37:53 2017
> > New Revision: 312467
> >
> > URL: http://llvm.org/viewvc/llvm-project?rev=312467=rev
> > Log:
> > Implement Itanium name mangling support for C++ Modules TS.
> >
> > This follows the scheme agreed with Nathan Sidwell, which can be found
> here:
> >
> >   https://gcc.gnu.org/wiki/cxx-modules?action=AttachFile
> >
> > This will be proposed to the itanium-cxx-abi list once we have some
> experience
> > with how well it works; the ABI for this TS should be considered
> unstable until
> > it is part of the Itanium C++ ABI.
> >
> > Modified:
> > cfe/trunk/include/clang/AST/Decl.h
> > cfe/trunk/include/clang/AST/DeclBase.h
> > cfe/trunk/include/clang/Basic/Module.h
> > cfe/trunk/include/clang/Lex/ModuleMap.h
> > cfe/trunk/lib/AST/Decl.cpp
> > cfe/trunk/lib/AST/ItaniumMangle.cpp
> > cfe/trunk/lib/Lex/ModuleMap.cpp
> > cfe/trunk/lib/Sema/Sema.cpp
> > cfe/trunk/lib/Sema/SemaDecl.cpp
> > cfe/trunk/lib/Serialization/ASTReader.cpp
> > cfe/trunk/lib/Serialization/ASTWriter.cpp
> > cfe/trunk/test/CXX/modules-ts/basic/basic.def.odr/p4/module.cpp
> > cfe/trunk/test/CXX/modules-ts/basic/basic.def.odr/p4/module.cppm
> > cfe/trunk/test/CXX/modules-ts/basic/basic.def.odr/p4/user.cpp
> > cfe/trunk/test/CXX/modules-ts/codegen-basics.cppm
> > cfe/trunk/test/SemaCXX/modules-ts.cppm
> >
> > Modified: cfe/trunk/include/clang/AST/Decl.h
> > URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/
> 

RE: r312542 - [Preprocessor] Correct internal token parsing of newline characters in CRLF

2017-09-05 Thread Keane, Erich via cfe-commits
There’s an existing test in r311683.  I’d initially implemented handling ‘\r\n’ 
as well as ‘\n\r’, but Reid had suggested that I simply handle the former.  I’d 
inadvertently contributed the previous revision.  I noticed this morning that 
I’d done so, so I corrected my commit.

From: tha...@google.com [mailto:tha...@google.com] On Behalf Of Nico Weber
Sent: Tuesday, September 5, 2017 1:47 PM
To: Keane, Erich 
Cc: cfe-commits 
Subject: Re: r312542 - [Preprocessor] Correct internal token parsing of newline 
characters in CRLF

Test?

On Tue, Sep 5, 2017 at 1:32 PM, Erich Keane via cfe-commits 
> wrote:
Author: erichkeane
Date: Tue Sep  5 10:32:36 2017
New Revision: 312542

URL: http://llvm.org/viewvc/llvm-project?rev=312542=rev
Log:
[Preprocessor] Correct internal token parsing of newline characters in CRLF

Correct implementation:  Apparently I managed in r311683 to submit the wrong
version of the patch for this, so I'm correcting it now.

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

Modified:
cfe/trunk/lib/Lex/Lexer.cpp

Modified: cfe/trunk/lib/Lex/Lexer.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/Lexer.cpp?rev=312542=312541=312542=diff
==
--- cfe/trunk/lib/Lex/Lexer.cpp (original)
+++ cfe/trunk/lib/Lex/Lexer.cpp Tue Sep  5 10:32:36 2017
@@ -3071,10 +3071,11 @@ LexNextToken:
 Kind = tok::unknown;
 break;

-  case '\n':
   case '\r':
-if (CurPtr[0] != Char && (CurPtr[0] == '\n' || CurPtr[0] == '\r'))
+if (CurPtr[0] == '\n')
   Char = getAndAdvanceChar(CurPtr, Result);
+LLVM_FALLTHROUGH;
+  case '\n':
 // If we are inside a preprocessor directive and we see the end of line,
 // we know we are done with the directive, so return an EOD token.
 if (ParsingPreprocessorDirective) {


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

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


Re: r312542 - [Preprocessor] Correct internal token parsing of newline characters in CRLF

2017-09-05 Thread Nico Weber via cfe-commits
Test?

On Tue, Sep 5, 2017 at 1:32 PM, Erich Keane via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: erichkeane
> Date: Tue Sep  5 10:32:36 2017
> New Revision: 312542
>
> URL: http://llvm.org/viewvc/llvm-project?rev=312542=rev
> Log:
> [Preprocessor] Correct internal token parsing of newline characters in CRLF
>
> Correct implementation:  Apparently I managed in r311683 to submit the
> wrong
> version of the patch for this, so I'm correcting it now.
>
> Differential Revision: https://reviews.llvm.org/D37079
>
> Modified:
> cfe/trunk/lib/Lex/Lexer.cpp
>
> Modified: cfe/trunk/lib/Lex/Lexer.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/
> Lexer.cpp?rev=312542=312541=312542=diff
> 
> ==
> --- cfe/trunk/lib/Lex/Lexer.cpp (original)
> +++ cfe/trunk/lib/Lex/Lexer.cpp Tue Sep  5 10:32:36 2017
> @@ -3071,10 +3071,11 @@ LexNextToken:
>  Kind = tok::unknown;
>  break;
>
> -  case '\n':
>case '\r':
> -if (CurPtr[0] != Char && (CurPtr[0] == '\n' || CurPtr[0] == '\r'))
> +if (CurPtr[0] == '\n')
>Char = getAndAdvanceChar(CurPtr, Result);
> +LLVM_FALLTHROUGH;
> +  case '\n':
>  // If we are inside a preprocessor directive and we see the end of
> line,
>  // we know we are done with the directive, so return an EOD token.
>  if (ParsingPreprocessorDirective) {
>
>
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D37448: Fix cast assertion on MS inline assembly with vector spills (PR34021)

2017-09-05 Thread Eli Friedman via Phabricator via cfe-commits
efriedma added a comment.

> According to our definition, v4si is NOT a "Vector" type, since a vector type 
> requires it be a FP value.

Umm, what?  An integer vector is still a vector.  The backend will return it in 
xmm0 on x86 (both 32 and 64-bit).

The actual problem here is that 
X86_32TargetCodeGenInfo::addReturnRegisterOutputs is adding outputs which don't 
make any sense; 32-bit x86 only returns integers and pointers (and maybe a few 
other weird things like complex integers and tiny vectors?) in EAX:EDX.   So we 
shouldn't add a constraint which involves those registers if the function 
returns a 128-bit vector (which goes in xmm0), or a struct (which is returned 
in memory), or a float (which is returned in an x87 register), etc.

Adding the "right" constraint for stuff that isn't returned in EAX would be 
nice, but probably isn't necessary unless we actually run into code which 
depends on it.


Repository:
  rL LLVM

https://reviews.llvm.org/D37448



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


r312573 - Commit changes missing from r312572

2017-09-05 Thread Reid Kleckner via cfe-commits
Author: rnk
Date: Tue Sep  5 13:38:29 2017
New Revision: 312573

URL: http://llvm.org/viewvc/llvm-project?rev=312573=rev
Log:
Commit changes missing from r312572

Modified:
cfe/trunk/lib/CodeGen/CGBuiltin.cpp
cfe/trunk/test/CodeGen/ms-annotation.c

Modified: cfe/trunk/lib/CodeGen/CGBuiltin.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGBuiltin.cpp?rev=312573=312572=312573=diff
==
--- cfe/trunk/lib/CodeGen/CGBuiltin.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGBuiltin.cpp Tue Sep  5 13:38:29 2017
@@ -1971,7 +1971,7 @@ RValue CodeGenFunction::EmitBuiltinExpr(
 }
 
 // Build and MDTuple of MDStrings and emit the intrinsic call.
-llvm::Value *F = CGM.getIntrinsic(llvm::Intrinsic::label_annotation, {});
+llvm::Value *F = CGM.getIntrinsic(llvm::Intrinsic::codeview_annotation, 
{});
 MDTuple *StrTuple = MDTuple::get(getLLVMContext(), Strings);
 Builder.CreateCall(F, MetadataAsValue::get(getLLVMContext(), StrTuple));
 return RValue::getIgnored();

Modified: cfe/trunk/test/CodeGen/ms-annotation.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/ms-annotation.c?rev=312573=312572=312573=diff
==
--- cfe/trunk/test/CodeGen/ms-annotation.c (original)
+++ cfe/trunk/test/CodeGen/ms-annotation.c Tue Sep  5 13:38:29 2017
@@ -12,11 +12,11 @@ void test1(void) {
 }
 
 // CHECK-LABEL: define void @test1()
-// CHECK: call void @llvm.label.annotation(metadata ![[A1:[0-9]+]])
-// CHECK: call void @llvm.label.annotation(metadata ![[A2:[0-9]+]])
-// CHECK: call void @llvm.label.annotation(metadata ![[A3:[0-9]+]])
-// CHECK: call void @llvm.label.annotation(metadata ![[A4:[0-9]+]])
-// CHECK: call void @llvm.label.annotation(metadata ![[A5:[0-9]+]])
+// CHECK: call void @llvm.codeview.annotation(metadata ![[A1:[0-9]+]])
+// CHECK: call void @llvm.codeview.annotation(metadata ![[A2:[0-9]+]])
+// CHECK: call void @llvm.codeview.annotation(metadata ![[A3:[0-9]+]])
+// CHECK: call void @llvm.codeview.annotation(metadata ![[A4:[0-9]+]])
+// CHECK: call void @llvm.codeview.annotation(metadata ![[A5:[0-9]+]])
 // CHECK: ret void
 
 // CHECK: ![[A1]] = !{!"a1"}


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


Re: r312467 - Implement Itanium name mangling support for C++ Modules TS.

2017-09-05 Thread Evgenii Stepanov via cfe-commits
Hi Richard,

this change has triggered a bunch of leak reports on the sanitizer bots:

Direct leak of 1824 byte(s) in 1 object(s) allocated from:
#0 0xb48430 in operator new(unsigned long)
/mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/projects/compiler-rt/lib/asan/asan_new_delete.cc:82
#1 0xadfd119 in
clang::ModuleMap::createGlobalModuleForInterfaceUnit(clang::SourceLocation)
/mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/tools/clang/lib/Lex/ModuleMap.cpp:750:18
#2 0x860e9be in clang::Sema::ActOnStartOfTranslationUnit()
/mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/tools/clang/lib/Sema/Sema.cpp:775:30
#3 0x7d27209 in
clang::Parser::ParseFirstTopLevelDecl(clang::OpaquePtr&)
/mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/tools/clang/lib/Parse/Parser.cpp:529:11
#4 0x7d158fe in clang::ParseAST(clang::Sema&, bool, bool)
/mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/tools/clang/lib/Parse/ParseAST.cpp:146:23
#5 0x618926e in clang::FrontendAction::Execute()
/mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/tools/clang/lib/Frontend/FrontendAction.cpp:902:8
#6 0x6090664 in
clang::CompilerInstance::ExecuteAction(clang::FrontendAction&)
/mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/tools/clang/lib/Frontend/CompilerInstance.cpp:986:11
#7 0x637eb45 in
clang::ExecuteCompilerInvocation(clang::CompilerInstance*)
/mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/tools/clang/lib/FrontendTool/ExecuteCompilerInvocation.cpp:252:25
#8 0xb5b13f in cc1_main(llvm::ArrayRef, char const*,
void*) 
/mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/tools/clang/tools/driver/cc1_main.cpp:221:13
#9 0xb53d33 in ExecuteCC1Tool
/mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/tools/clang/tools/driver/driver.cpp:302:12
#10 0xb53d33 in main
/mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/tools/clang/tools/driver/driver.cpp:381
#11 0x7fc921b0b82f in __libc_start_main
(/lib/x86_64-linux-gnu/libc.so.6+0x2082f)

Failing Tests (16):
Clang :: CXX/modules-ts/basic/basic.def.odr/p4/module.cpp
Clang :: CXX/modules-ts/basic/basic.def.odr/p4/user.cpp
Clang :: CXX/modules-ts/basic/basic.link/module-declaration.cpp
Clang :: CXX/modules-ts/basic/basic.link/p2/module.cpp
Clang :: CXX/modules-ts/basic/basic.link/p2/other.cpp
Clang :: CXX/modules-ts/basic/basic.search/module-import.cpp
Clang :: CXX/modules-ts/codegen-basics.cppm
Clang :: CXX/modules-ts/dcl.dcl/dcl.module/dcl.module.import/p1.cpp
Clang :: CXX/modules-ts/dcl.dcl/dcl.module/dcl.module.interface/p1.cpp
Clang :: CXX/modules-ts/dcl.dcl/dcl.module/p5.cpp
Clang :: Driver/modules-ts.cpp
Clang :: Lexer/modules-ts.cpp
Clang :: Modules/diag-flags.cpp
Clang :: Modules/diag-pragma.cpp
Clang :: Modules/import-syntax.c
Clang :: SemaCXX/modules-ts.cppm

http://lab.llvm.org:8011/builders/sanitizer-x86_64-linux-fast/builds/7630

On Sun, Sep 3, 2017 at 10:37 PM, Richard Smith via cfe-commits
 wrote:
> Author: rsmith
> Date: Sun Sep  3 22:37:53 2017
> New Revision: 312467
>
> URL: http://llvm.org/viewvc/llvm-project?rev=312467=rev
> Log:
> Implement Itanium name mangling support for C++ Modules TS.
>
> This follows the scheme agreed with Nathan Sidwell, which can be found here:
>
>   https://gcc.gnu.org/wiki/cxx-modules?action=AttachFile
>
> This will be proposed to the itanium-cxx-abi list once we have some experience
> with how well it works; the ABI for this TS should be considered unstable 
> until
> it is part of the Itanium C++ ABI.
>
> Modified:
> cfe/trunk/include/clang/AST/Decl.h
> cfe/trunk/include/clang/AST/DeclBase.h
> cfe/trunk/include/clang/Basic/Module.h
> cfe/trunk/include/clang/Lex/ModuleMap.h
> cfe/trunk/lib/AST/Decl.cpp
> cfe/trunk/lib/AST/ItaniumMangle.cpp
> cfe/trunk/lib/Lex/ModuleMap.cpp
> cfe/trunk/lib/Sema/Sema.cpp
> cfe/trunk/lib/Sema/SemaDecl.cpp
> cfe/trunk/lib/Serialization/ASTReader.cpp
> cfe/trunk/lib/Serialization/ASTWriter.cpp
> cfe/trunk/test/CXX/modules-ts/basic/basic.def.odr/p4/module.cpp
> cfe/trunk/test/CXX/modules-ts/basic/basic.def.odr/p4/module.cppm
> cfe/trunk/test/CXX/modules-ts/basic/basic.def.odr/p4/user.cpp
> cfe/trunk/test/CXX/modules-ts/codegen-basics.cppm
> cfe/trunk/test/SemaCXX/modules-ts.cppm
>
> Modified: cfe/trunk/include/clang/AST/Decl.h
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Decl.h?rev=312467=312466=312467=diff
> ==
> --- cfe/trunk/include/clang/AST/Decl.h (original)
> +++ cfe/trunk/include/clang/AST/Decl.h Sun Sep  3 22:37:53 2017
> @@ -372,6 +372,10 @@ public:
>  return hasCachedLinkage();
>}
>
> +  /// Get the module that owns this declaration 

r312572 - [ms] Implement the __annotation intrinsic

2017-09-05 Thread Reid Kleckner via cfe-commits
Author: rnk
Date: Tue Sep  5 13:27:35 2017
New Revision: 312572

URL: http://llvm.org/viewvc/llvm-project?rev=312572=rev
Log:
[ms] Implement the __annotation intrinsic

Added:
cfe/trunk/test/CodeGen/ms-annotation.c
cfe/trunk/test/Sema/ms-annotation.c
Modified:
cfe/trunk/include/clang/Basic/Builtins.def
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
cfe/trunk/lib/CodeGen/CGBuiltin.cpp
cfe/trunk/lib/Sema/SemaChecking.cpp

Modified: cfe/trunk/include/clang/Basic/Builtins.def
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Builtins.def?rev=312572=312571=312572=diff
==
--- cfe/trunk/include/clang/Basic/Builtins.def (original)
+++ cfe/trunk/include/clang/Basic/Builtins.def Tue Sep  5 13:27:35 2017
@@ -732,6 +732,7 @@ BUILTIN(__builtin_rindex, "c*cC*i", "Fn"
 
 // Microsoft builtins.  These are only active with -fms-extensions.
 LANGBUILTIN(_alloca,  "v*z", "n", ALL_MS_LANGUAGES)
+LANGBUILTIN(__annotation, "wC*.","n", ALL_MS_LANGUAGES)
 LANGBUILTIN(__assume, "vb",  "n", ALL_MS_LANGUAGES)
 LIBBUILTIN(_byteswap_ushort, "UsUs", "fnc", "stdlib.h", ALL_MS_LANGUAGES)
 LIBBUILTIN(_byteswap_ulong,  "UNiUNi",   "fnc", "stdlib.h", ALL_MS_LANGUAGES)

Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=312572=312571=312572=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Tue Sep  5 13:27:35 
2017
@@ -7902,6 +7902,8 @@ def err_builtin_annotation_first_arg : E
   "first argument to __builtin_annotation must be an integer">;
 def err_builtin_annotation_second_arg : Error<
   "second argument to __builtin_annotation must be a non-wide string 
constant">;
+def err_msvc_annotation_wide_str : Error<
+  "arguments to __annotation must be wide string constants">;
 
 // CFString checking
 def err_cfstring_literal_not_string_constant : Error<

Modified: cfe/trunk/lib/CodeGen/CGBuiltin.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGBuiltin.cpp?rev=312572=312571=312572=diff
==
--- cfe/trunk/lib/CodeGen/CGBuiltin.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGBuiltin.cpp Tue Sep  5 13:27:35 2017
@@ -30,6 +30,7 @@
 #include "llvm/IR/InlineAsm.h"
 #include "llvm/IR/Intrinsics.h"
 #include "llvm/IR/MDBuilder.h"
+#include "llvm/Support/ConvertUTF.h"
 #include 
 
 using namespace clang;
@@ -1953,6 +1954,28 @@ RValue CodeGenFunction::EmitBuiltinExpr(
 Builder.CreateZExt(EmitSignBit(*this, EmitScalarExpr(E->getArg(0))),
ConvertType(E->getType(;
   }
+  case Builtin::BI__annotation: {
+// Re-encode each wide string to UTF8 and make an MDString.
+SmallVector Strings;
+for (const Expr *Arg : E->arguments()) {
+  const auto *Str = cast(Arg->IgnoreParenCasts());
+  assert(Str->getCharByteWidth() == 2);
+  StringRef WideBytes = Str->getBytes();
+  std::string StrUtf8;
+  if (!convertUTF16ToUTF8String(
+  makeArrayRef(WideBytes.data(), WideBytes.size()), StrUtf8)) {
+CGM.ErrorUnsupported(E, "non-UTF16 __annotation argument");
+continue;
+  }
+  Strings.push_back(llvm::MDString::get(getLLVMContext(), StrUtf8));
+}
+
+// Build and MDTuple of MDStrings and emit the intrinsic call.
+llvm::Value *F = CGM.getIntrinsic(llvm::Intrinsic::label_annotation, {});
+MDTuple *StrTuple = MDTuple::get(getLLVMContext(), Strings);
+Builder.CreateCall(F, MetadataAsValue::get(getLLVMContext(), StrTuple));
+return RValue::getIgnored();
+  }
   case Builtin::BI__builtin_annotation: {
 llvm::Value *AnnVal = EmitScalarExpr(E->getArg(0));
 llvm::Value *F = CGM.getIntrinsic(llvm::Intrinsic::annotation,

Modified: cfe/trunk/lib/Sema/SemaChecking.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaChecking.cpp?rev=312572=312571=312572=diff
==
--- cfe/trunk/lib/Sema/SemaChecking.cpp (original)
+++ cfe/trunk/lib/Sema/SemaChecking.cpp Tue Sep  5 13:27:35 2017
@@ -99,6 +99,28 @@ static bool SemaBuiltinAnnotation(Sema &
   return false;
 }
 
+static bool SemaBuiltinMSVCAnnotation(Sema , CallExpr *TheCall) {
+  // We need at least one argument.
+  if (TheCall->getNumArgs() < 1) {
+S.Diag(TheCall->getLocEnd(), 
diag::err_typecheck_call_too_few_args_at_least)
+<< 0 << 1 << TheCall->getNumArgs()
+<< TheCall->getCallee()->getSourceRange();
+return true;
+  }
+
+  // All arguments should be wide string literals.
+  for (Expr *Arg : TheCall->arguments()) {
+auto *Literal = dyn_cast(Arg->IgnoreParenCasts());
+if (!Literal 

[PATCH] D37442: [C++17] Disallow lambdas in template parameters (PR33696).

2017-09-05 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith added inline comments.



Comment at: include/clang/Sema/Sema.h:979-980
   Decl *ManglingContextDecl,
-  bool IsDecltype)
+  bool IsDecltype,
+  bool IsLambdaValid)
   : Context(Context), ParentCleanup(ParentCleanup),

Instead of a sequence of `bool`s, can you add an enum for `decltype` / template 
argument / other?


https://reviews.llvm.org/D37442



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


[PATCH] D37448: Fix cast assertion on MS inline assembly with vector spills (PR34021)

2017-09-05 Thread Erich Keane via Phabricator via cfe-commits
erichkeane added a comment.

In https://reviews.llvm.org/D37448#861211, @rnk wrote:

> I think this is a reasonable stop-gap fix since the code isn't trying to 
> return EAX:EDX or XMM0 from the inline asm blob. This affects any function 
> that contains inline asm and returns a vector, which is potentially a lot of 
> stuff.


Actually... I've convinced myself that this is likely the correct fix for this 
bug.  There is likely a separate bug for vector-types and struct return types, 
however I'd believe those aren't really things that anyone else supports.

According to our definition, v4si is NOT a "Vector" type, since a vector type 
requires it be a FP value.  SO, we are converting an integer stored in eax/edx 
to a wider integer.  Since assembly doesn't have a 'signed'-ness, I would 
assert that widening a register-stored variable to via zero-ext is the correct 
fix here.

In summary, I believe this is the correct fix for the bug as reported.


Repository:
  rL LLVM

https://reviews.llvm.org/D37448



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


[PATCH] D37491: [Preamble] Fixed preamble breaking with BOM presence (and particularly, fluctuating BOM presence)

2017-09-05 Thread Cameron via Phabricator via cfe-commits
cameron314 created this revision.

This patch fixes preamble skipping when the preamble region includes a byte 
order mark (BOM). Previously, parsing would fail if preamble PCH generation was 
enabled and a BOM was present.

This also fixes the preamble incorrectly being invalidated when a BOM appeared 
or disappeared, even if the contents after the BOM had not changed. This may 
seem to be an obscure edge case, but it is important for IDEs that pass buffer 
overrides that never (or always) have a BOM, yet the underlying file from the 
initial parse that generated a PCH might (or might not) have a BOM.

Test cases for these scenarios are included.

Note: This depends on the test infrastructure introduced in 
https://reviews.llvm.org/D37474.


https://reviews.llvm.org/D37491

Files:
  include/clang/Frontend/PrecompiledPreamble.h
  include/clang/Lex/Lexer.h
  include/clang/Lex/PreprocessorOptions.h
  lib/Frontend/ASTUnit.cpp
  lib/Frontend/FrontendActions.cpp
  lib/Frontend/PrecompiledPreamble.cpp
  lib/Lex/Lexer.cpp
  lib/Lex/Preprocessor.cpp
  unittests/Frontend/PchPreambleTest.cpp

Index: unittests/Frontend/PchPreambleTest.cpp
===
--- unittests/Frontend/PchPreambleTest.cpp
+++ unittests/Frontend/PchPreambleTest.cpp
@@ -91,8 +91,19 @@
 PreprocessorOptions  = CI->getPreprocessorOpts();
 PPOpts.RemappedFilesKeepOriginalName = true;
 
+struct DebugConsumer : DiagnosticConsumer
+{
+  void HandleDiagnostic(DiagnosticsEngine::Level DiagLevel,
+const Diagnostic ) override {
+DiagnosticConsumer::HandleDiagnostic(DiagLevel, Info);
+SmallString<16> DiagText;
+Info.FormatDiagnostic(DiagText);
+llvm::errs() << DiagText << '\n';
+  }
+};
+
 IntrusiveRefCntPtr
-  Diags(CompilerInstance::createDiagnostics(new DiagnosticOptions, new DiagnosticConsumer));
+  Diags(CompilerInstance::createDiagnostics(new DiagnosticOptions, new DebugConsumer));
 
 FileManager *FileMgr = new FileManager(FSOpts, VFS);
 
@@ -153,4 +164,64 @@
   ASSERT_EQ(initialCounts[2], GetFileReadCount(Header2));
 }
 
+TEST_F(PchPreambleTest, ReparseWithDisappearingBom) {
+  std::string Header = "//./header.h";
+  std::string Main = "//./main.cpp";
+  AddFile(Header, "int random() { return 4; }");
+  AddFile(Main,
+"\xef\xbb\xbf"
+"#include \"//./header.h\"\n"
+"int main() { return random() * 2; }");
+
+  std::unique_ptr AST(ParseAST(Main));
+  ASSERT_TRUE(AST.get());
+  ASSERT_FALSE(AST->getDiagnostics().hasErrorOccurred());
+
+  unsigned initialCounts[] = {
+GetFileReadCount(Main),
+GetFileReadCount(Header)
+  };
+
+  // Remove BOM but keep the rest the same
+  RemapFile(Main,
+"#include \"//./header.h\"\n"
+"int main() { return random() * 2; }");
+
+  ASSERT_TRUE(ReparseAST(AST));
+  ASSERT_FALSE(AST->getDiagnostics().hasErrorOccurred());
+
+  ASSERT_EQ(initialCounts[0], GetFileReadCount(Main));
+  ASSERT_EQ(initialCounts[1], GetFileReadCount(Header));
+}
+
+TEST_F(PchPreambleTest, ReparseWithAppearingBom) {
+  std::string Header = "//./header.h";
+  std::string Main = "//./main.cpp";
+  AddFile(Header, "int random() { return 4; }");
+  AddFile(Main,
+"#include \"//./header.h\"\n"
+"int main() { return random() * 2; }");
+
+  std::unique_ptr AST(ParseAST(Main));
+  ASSERT_TRUE(AST.get());
+  ASSERT_FALSE(AST->getDiagnostics().hasErrorOccurred());
+
+  unsigned initialCounts[] = {
+GetFileReadCount(Main),
+GetFileReadCount(Header)
+  };
+
+  // Suddenly, a BOM appeared
+  RemapFile(Main,
+"\xef\xbb\xbf"
+"#include \"//./header.h\"\n"
+"int main() { return random() * 2; }");
+
+  ASSERT_TRUE(ReparseAST(AST));
+  ASSERT_FALSE(AST->getDiagnostics().hasErrorOccurred());
+
+  ASSERT_EQ(initialCounts[0], GetFileReadCount(Main));
+  ASSERT_EQ(initialCounts[1], GetFileReadCount(Header));
+}
+
 } // anonymous namespace
Index: lib/Lex/Preprocessor.cpp
===
--- lib/Lex/Preprocessor.cpp
+++ lib/Lex/Preprocessor.cpp
@@ -516,9 +516,9 @@
 // If we've been asked to skip bytes in the main file (e.g., as part of a
 // precompiled preamble), do so now.
 if (SkipMainFilePreamble.first > 0)
-  CurLexer->SkipBytes(SkipMainFilePreamble.first, 
-  SkipMainFilePreamble.second);
-
+  CurLexer->SetByteOffset(SkipMainFilePreamble.first,
+  SkipMainFilePreamble.second);
+
 // Tell the header info that the main file was entered.  If the file is later
 // #imported, it won't be re-entered.
 if (const FileEntry *FE = SourceMgr.getFileEntryForID(MainFileID))
Index: lib/Lex/Lexer.cpp
===
--- lib/Lex/Lexer.cpp
+++ lib/Lex/Lexer.cpp
@@ -552,9 +552,9 @@
 
 } // end anonymous namespace
 
-std::pair Lexer::ComputePreamble(StringRef Buffer,
-   

[PATCH] D37101: [clangd] Add support for snippet completions

2017-09-05 Thread Raoul Wols via Phabricator via cfe-commits
rwols marked 7 inline comments as done.
rwols added inline comments.



Comment at: clangd/ClangdUnit.cpp:376
+
+CompletionItem Item{InsertTextFormat::PlainText};
+

ilya-biryukov wrote:
> Implementations of this function in `PlainTextCompletionItemsCollector` and 
> `SnippetCompletionItemsCollector` are the same.
> Maybe make `ProcessChunks` virtual instead?
> 
> Or maybe consider replacing inheritance with a `bool` flag. Inheritance does 
> not seem to buy us much here. This looks simpler:
> ```
> if (EnableSnippets)
>   ProcessChunksWithSnippets(CCS, Item);
> else
>   ProcessChunksWithoutSnippets(CCS, Item);
> 
> ```
> 
> 
I went with the "make ProcessChunks virtual" approach, wouldn't your suggestion 
have an impact on performance? There'd be a check for every completion item now.


https://reviews.llvm.org/D37101



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


[PATCH] D37101: [clangd] Add support for snippet completions

2017-09-05 Thread Raoul Wols via Phabricator via cfe-commits
rwols updated this revision to Diff 113899.
rwols added a comment.

- Don't use const for non-reference parameters
- `lowerCamelCase` for functions, verb phrase
- Field definitions at the bottom of the class
- Make ProcessChunks virtual
- Add comment that fallthrough to the next case is intended
- Revert new constructors for CompletionItem, they are pointless
- Bump minimum version for vscode-languageclient and vscode-languageserver to 
3.3.0


https://reviews.llvm.org/D37101

Files:
  clangd/ClangdLSPServer.cpp
  clangd/ClangdLSPServer.h
  clangd/ClangdServer.cpp
  clangd/ClangdServer.h
  clangd/ClangdUnit.cpp
  clangd/ClangdUnit.h
  clangd/Protocol.cpp
  clangd/clients/clangd-vscode/package.json
  clangd/tool/ClangdMain.cpp
  test/clangd/authority-less-uri.test
  test/clangd/completion-snippet.test
  test/clangd/completion.test

Index: test/clangd/completion.test
===
--- test/clangd/completion.test
+++ test/clangd/completion.test
@@ -16,25 +16,25 @@
 # nondeterministic, so we check regardless of order.
 #
 # CHECK: {"jsonrpc":"2.0","id":1,"result":[
-# CHECK-DAG: {"label":"a","kind":5,"detail":"int","sortText":"00035a","filterText":"a","insertText":"a"}
-# CHECK-DAG: {"label":"bb","kind":5,"detail":"int","sortText":"00035bb","filterText":"bb","insertText":"bb"}
-# CHECK-DAG: {"label":"ccc","kind":5,"detail":"int","sortText":"00035ccc","filterText":"ccc","insertText":"ccc"}
-# CHECK-DAG: {"label":"operator=(const fake &)","kind":2,"detail":"fake &","sortText":"00034operator=","filterText":"operator=","insertText":"operator="}
-# CHECK-DAG: {"label":"~fake()","kind":4,"detail":"void","sortText":"00034~fake","filterText":"~fake","insertText":"~fake"}
-# CHECK-DAG: {"label":"f(int i, const float f) const","kind":2,"detail":"int","sortText":"00035f","filterText":"f","insertText":"f"}
+# CHECK-DAG: {"label":"a","kind":5,"detail":"int","sortText":"00035a","filterText":"a","insertText":"a","insertTextFormat":1}
+# CHECK-DAG: {"label":"bb","kind":5,"detail":"int","sortText":"00035bb","filterText":"bb","insertText":"bb","insertTextFormat":1}
+# CHECK-DAG: {"label":"ccc","kind":5,"detail":"int","sortText":"00035ccc","filterText":"ccc","insertText":"ccc","insertTextFormat":1}
+# CHECK-DAG: {"label":"operator=(const fake &)","kind":2,"detail":"fake &","sortText":"00034operator=","filterText":"operator=","insertText":"operator=","insertTextFormat":1}
+# CHECK-DAG: {"label":"~fake()","kind":4,"detail":"void","sortText":"00034~fake","filterText":"~fake","insertText":"~fake","insertTextFormat":1}
+# CHECK-DAG: {"label":"f(int i, const float f) const","kind":2,"detail":"int","sortText":"00035f","filterText":"f","insertText":"f","insertTextFormat":1}
 # CHECK: ]}
 Content-Length: 148
 
 {"jsonrpc":"2.0","id":2,"method":"textDocument/completion","params":{"textDocument":{"uri":"file:///main.cpp"},"position":{"line":3,"character":5}}}
 # Repeat the completion request, expect the same results.
 #
 # CHECK: {"jsonrpc":"2.0","id":2,"result":[
-# CHECK-DAG: {"label":"a","kind":5,"detail":"int","sortText":"00035a","filterText":"a","insertText":"a"}
-# CHECK-DAG: {"label":"bb","kind":5,"detail":"int","sortText":"00035bb","filterText":"bb","insertText":"bb"}
-# CHECK-DAG: {"label":"ccc","kind":5,"detail":"int","sortText":"00035ccc","filterText":"ccc","insertText":"ccc"}
-# CHECK-DAG: {"label":"operator=(const fake &)","kind":2,"detail":"fake &","sortText":"00034operator=","filterText":"operator=","insertText":"operator="}
-# CHECK-DAG: {"label":"~fake()","kind":4,"detail":"void","sortText":"00034~fake","filterText":"~fake","insertText":"~fake"}
-# CHECK-DAG: {"label":"f(int i, const float f) const","kind":2,"detail":"int","sortText":"00035f","filterText":"f","insertText":"f"}
+# CHECK-DAG: {"label":"a","kind":5,"detail":"int","sortText":"00035a","filterText":"a","insertText":"a","insertTextFormat":1}
+# CHECK-DAG: {"label":"bb","kind":5,"detail":"int","sortText":"00035bb","filterText":"bb","insertText":"bb","insertTextFormat":1}
+# CHECK-DAG: {"label":"ccc","kind":5,"detail":"int","sortText":"00035ccc","filterText":"ccc","insertText":"ccc","insertTextFormat":1}
+# CHECK-DAG: {"label":"operator=(const fake &)","kind":2,"detail":"fake &","sortText":"00034operator=","filterText":"operator=","insertText":"operator=","insertTextFormat":1}
+# CHECK-DAG: {"label":"~fake()","kind":4,"detail":"void","sortText":"00034~fake","filterText":"~fake","insertText":"~fake","insertTextFormat":1}
+# CHECK-DAG: {"label":"f(int i, const float f) const","kind":2,"detail":"int","sortText":"00035f","filterText":"f","insertText":"f","insertTextFormat":1}
 # CHECK: ]}
 # Update the source file and check for completions again.
 Content-Length: 226
@@ -47,7 +47,7 @@
 # Repeat the completion request, expect the same results.
 #
 # CHECK: {"jsonrpc":"2.0","id":3,"result":[
-# CHECK-DAG: {"label":"func()","kind":2,"detail":"int (*)(int, 

[PATCH] D37490: Fix __repr__ for Diagnostic in clang.cindex

2017-09-05 Thread Jonathan B Coe via Phabricator via cfe-commits
jbcoe created this revision.
jbcoe added a project: clang-c.

Also move misplaced tests for exception specification to fix failing Python 
tests.


Repository:
  rL LLVM

https://reviews.llvm.org/D37490

Files:
  clang/bindings/python/clang/cindex.py
  clang/bindings/python/tests/cindex/test_diagnostics.py
  clang/bindings/python/tests/cindex/test_exception_specification_kind.py
  clang/bindings/python/tests/test_exception_specification_kind.py


Index: clang/bindings/python/tests/cindex/test_diagnostics.py
===
--- clang/bindings/python/tests/cindex/test_diagnostics.py
+++ clang/bindings/python/tests/cindex/test_diagnostics.py
@@ -92,3 +92,11 @@
 assert children[0].spelling.endswith('declared here')
 assert children[0].location.line == 1
 assert children[0].location.column == 1
+
+def test_diagnostic_string_repr():
+tu = get_tu('struct MissingSemicolon{}')
+assert len(tu.diagnostics) == 1
+d = tu.diagnostics[0]
+
+assert repr(d) == ', spelling "expected \';\' after struct">'
+
Index: clang/bindings/python/clang/cindex.py
===
--- clang/bindings/python/clang/cindex.py
+++ clang/bindings/python/clang/cindex.py
@@ -207,7 +207,7 @@
 conf.lib.clang_disposeString(self)
 
 @staticmethod
-def from_result(res, fn, args):
+def from_result(res, fn=None, args=None):
 assert isinstance(res, _CXString)
 return conf.lib.clang_getCString(res)
 
@@ -459,8 +459,7 @@
 """The command-line option that disables this diagnostic."""
 disable = _CXString()
 conf.lib.clang_getDiagnosticOption(self, byref(disable))
-
-return conf.lib.clang_getCString(disable)
+return _CXString.from_result(disable)
 
 def format(self, options=None):
 """
@@ -473,8 +472,7 @@
 options = conf.lib.clang_defaultDiagnosticDisplayOptions()
 if options & ~Diagnostic._FormatOptionsMask:
 raise ValueError('Invalid format options')
-formatted = conf.lib.clang_formatDiagnostic(self, options)
-return conf.lib.clang_getCString(formatted)
+return conf.lib.clang_formatDiagnostic(self, options)
 
 def __repr__(self):
 return "" % (


Index: clang/bindings/python/tests/cindex/test_diagnostics.py
===
--- clang/bindings/python/tests/cindex/test_diagnostics.py
+++ clang/bindings/python/tests/cindex/test_diagnostics.py
@@ -92,3 +92,11 @@
 assert children[0].spelling.endswith('declared here')
 assert children[0].location.line == 1
 assert children[0].location.column == 1
+
+def test_diagnostic_string_repr():
+tu = get_tu('struct MissingSemicolon{}')
+assert len(tu.diagnostics) == 1
+d = tu.diagnostics[0]
+
+assert repr(d) == ', spelling "expected \';\' after struct">'
+
Index: clang/bindings/python/clang/cindex.py
===
--- clang/bindings/python/clang/cindex.py
+++ clang/bindings/python/clang/cindex.py
@@ -207,7 +207,7 @@
 conf.lib.clang_disposeString(self)
 
 @staticmethod
-def from_result(res, fn, args):
+def from_result(res, fn=None, args=None):
 assert isinstance(res, _CXString)
 return conf.lib.clang_getCString(res)
 
@@ -459,8 +459,7 @@
 """The command-line option that disables this diagnostic."""
 disable = _CXString()
 conf.lib.clang_getDiagnosticOption(self, byref(disable))
-
-return conf.lib.clang_getCString(disable)
+return _CXString.from_result(disable)
 
 def format(self, options=None):
 """
@@ -473,8 +472,7 @@
 options = conf.lib.clang_defaultDiagnosticDisplayOptions()
 if options & ~Diagnostic._FormatOptionsMask:
 raise ValueError('Invalid format options')
-formatted = conf.lib.clang_formatDiagnostic(self, options)
-return conf.lib.clang_getCString(formatted)
+return conf.lib.clang_formatDiagnostic(self, options)
 
 def __repr__(self):
 return "" % (
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D37101: [clangd] Add support for snippet completions

2017-09-05 Thread Raoul Wols via Phabricator via cfe-commits
rwols updated this revision to Diff 113901.
rwols added a comment.

- Fix failing clangd tests


https://reviews.llvm.org/D37101

Files:
  clangd/ClangdLSPServer.cpp
  clangd/ClangdLSPServer.h
  clangd/ClangdServer.cpp
  clangd/ClangdServer.h
  clangd/ClangdUnit.cpp
  clangd/ClangdUnit.h
  clangd/Protocol.cpp
  clangd/clients/clangd-vscode/package.json
  clangd/tool/ClangdMain.cpp
  test/clangd/authority-less-uri.test
  test/clangd/completion-snippet.test
  test/clangd/completion.test

Index: test/clangd/completion.test
===
--- test/clangd/completion.test
+++ test/clangd/completion.test
@@ -1,4 +1,4 @@
-# RUN: clangd -run-synchronously < %s | FileCheck %s
+# RUN: clangd -run-synchronously -disable-snippets < %s | FileCheck %s
 # It is absolutely vital that this file has CRLF line endings.
 #
 Content-Length: 125
@@ -16,25 +16,25 @@
 # nondeterministic, so we check regardless of order.
 #
 # CHECK: {"jsonrpc":"2.0","id":1,"result":[
-# CHECK-DAG: {"label":"a","kind":5,"detail":"int","sortText":"00035a","filterText":"a","insertText":"a"}
-# CHECK-DAG: {"label":"bb","kind":5,"detail":"int","sortText":"00035bb","filterText":"bb","insertText":"bb"}
-# CHECK-DAG: {"label":"ccc","kind":5,"detail":"int","sortText":"00035ccc","filterText":"ccc","insertText":"ccc"}
-# CHECK-DAG: {"label":"operator=(const fake &)","kind":2,"detail":"fake &","sortText":"00034operator=","filterText":"operator=","insertText":"operator="}
-# CHECK-DAG: {"label":"~fake()","kind":4,"detail":"void","sortText":"00034~fake","filterText":"~fake","insertText":"~fake"}
-# CHECK-DAG: {"label":"f(int i, const float f) const","kind":2,"detail":"int","sortText":"00035f","filterText":"f","insertText":"f"}
+# CHECK-DAG: {"label":"a","kind":5,"detail":"int","sortText":"00035a","filterText":"a","insertText":"a","insertTextFormat":1}
+# CHECK-DAG: {"label":"bb","kind":5,"detail":"int","sortText":"00035bb","filterText":"bb","insertText":"bb","insertTextFormat":1}
+# CHECK-DAG: {"label":"ccc","kind":5,"detail":"int","sortText":"00035ccc","filterText":"ccc","insertText":"ccc","insertTextFormat":1}
+# CHECK-DAG: {"label":"operator=(const fake &)","kind":2,"detail":"fake &","sortText":"00034operator=","filterText":"operator=","insertText":"operator=","insertTextFormat":1}
+# CHECK-DAG: {"label":"~fake()","kind":4,"detail":"void","sortText":"00034~fake","filterText":"~fake","insertText":"~fake","insertTextFormat":1}
+# CHECK-DAG: {"label":"f(int i, const float f) const","kind":2,"detail":"int","sortText":"00035f","filterText":"f","insertText":"f","insertTextFormat":1}
 # CHECK: ]}
 Content-Length: 148
 
 {"jsonrpc":"2.0","id":2,"method":"textDocument/completion","params":{"textDocument":{"uri":"file:///main.cpp"},"position":{"line":3,"character":5}}}
 # Repeat the completion request, expect the same results.
 #
 # CHECK: {"jsonrpc":"2.0","id":2,"result":[
-# CHECK-DAG: {"label":"a","kind":5,"detail":"int","sortText":"00035a","filterText":"a","insertText":"a"}
-# CHECK-DAG: {"label":"bb","kind":5,"detail":"int","sortText":"00035bb","filterText":"bb","insertText":"bb"}
-# CHECK-DAG: {"label":"ccc","kind":5,"detail":"int","sortText":"00035ccc","filterText":"ccc","insertText":"ccc"}
-# CHECK-DAG: {"label":"operator=(const fake &)","kind":2,"detail":"fake &","sortText":"00034operator=","filterText":"operator=","insertText":"operator="}
-# CHECK-DAG: {"label":"~fake()","kind":4,"detail":"void","sortText":"00034~fake","filterText":"~fake","insertText":"~fake"}
-# CHECK-DAG: {"label":"f(int i, const float f) const","kind":2,"detail":"int","sortText":"00035f","filterText":"f","insertText":"f"}
+# CHECK-DAG: {"label":"a","kind":5,"detail":"int","sortText":"00035a","filterText":"a","insertText":"a","insertTextFormat":1}
+# CHECK-DAG: {"label":"bb","kind":5,"detail":"int","sortText":"00035bb","filterText":"bb","insertText":"bb","insertTextFormat":1}
+# CHECK-DAG: {"label":"ccc","kind":5,"detail":"int","sortText":"00035ccc","filterText":"ccc","insertText":"ccc","insertTextFormat":1}
+# CHECK-DAG: {"label":"operator=(const fake &)","kind":2,"detail":"fake &","sortText":"00034operator=","filterText":"operator=","insertText":"operator=","insertTextFormat":1}
+# CHECK-DAG: {"label":"~fake()","kind":4,"detail":"void","sortText":"00034~fake","filterText":"~fake","insertText":"~fake","insertTextFormat":1}
+# CHECK-DAG: {"label":"f(int i, const float f) const","kind":2,"detail":"int","sortText":"00035f","filterText":"f","insertText":"f","insertTextFormat":1}
 # CHECK: ]}
 # Update the source file and check for completions again.
 Content-Length: 226
@@ -47,7 +47,7 @@
 # Repeat the completion request, expect the same results.
 #
 # CHECK: {"jsonrpc":"2.0","id":3,"result":[
-# CHECK-DAG: {"label":"func()","kind":2,"detail":"int (*)(int, int)","sortText":"00034func","filterText":"func","insertText":"func"}
+# CHECK-DAG: {"label":"func()","kind":2,"detail":"int (*)(int, 

[PATCH] D37150: [clangd] Command line arg to specify compile_commands.json path

2017-09-05 Thread William Enright via Phabricator via cfe-commits
Nebiroth updated this revision to Diff 113895.
Nebiroth added a comment.

Added function to avoid code reuse and extra nesting.


https://reviews.llvm.org/D37150

Files:
  clangd/ClangdLSPServer.cpp
  clangd/ClangdLSPServer.h
  clangd/ClangdServer.cpp
  clangd/ClangdServer.h
  clangd/GlobalCompilationDatabase.cpp
  clangd/GlobalCompilationDatabase.h
  clangd/tool/ClangdMain.cpp
  test/clangd/hover.test

Index: test/clangd/hover.test
===
--- /dev/null
+++ test/clangd/hover.test
@@ -0,0 +1,26 @@
+# RUN: clangd -run-synchronously < %s | FileCheck %s
+# It is absolutely vital that this file has CRLF line endings.
+#
+Content-Length: 125
+
+{"jsonrpc":"2.0","id":0,"method":"initialize","params":{"processId":123,"rootPath":"clangd","capabilities":{},"trace":"off"}}
+
+Content-Length: 172
+
+{"jsonrpc":"2.0","method":"textDocument/didOpen","params":{"textDocument":{"uri":"file:///main.cpp","languageId":"cpp","version":1,"text":"int main() {\nint a;\na;\n}\n"}}}
+
+Content-Length: 143
+
+{"jsonrpc":"2.0","id":1,"method":"textDocument/hover","params":{"textDocument":{"uri":"file:///main.cpp"},"position":{"line":0,"character":5}}}
+# Go to local variable
+# CHECK: {"jsonrpc":"2.0","id":1,"result":{"contents": {"language": "C++", "value": "int main() {\nint a;\na;\n}"}, "range": {"start": {"line": 0, "character": 0}, "end": {"line": 3, "character": 1
+
+Content-Length: 143
+
+{"jsonrpc":"2.0","id":1,"method":"textDocument/hover","params":{"textDocument":{"uri":"file:///main.cpp"},"position":{"line":1,"character":5}}}
+# Go to local variable
+# CHECK: {"jsonrpc":"2.0","id":1,"result":{"contents": {"language": "C++", "value": "int a"}, "range": {"start": {"line": 1, "character": 0}, "end": {"line": 1, "character": 5
+
+Content-Length: 44
+
+{"jsonrpc":"2.0","id":3,"method":"shutdown"}
Index: clangd/tool/ClangdMain.cpp
===
--- clangd/tool/ClangdMain.cpp
+++ clangd/tool/ClangdMain.cpp
@@ -12,6 +12,7 @@
 #include "llvm/Support/CommandLine.h"
 #include "llvm/Support/FileSystem.h"
 #include "llvm/Support/Program.h"
+#include "llvm/Support/Path.h"
 
 #include 
 #include 
@@ -25,16 +26,29 @@
  llvm::cl::desc("parse on main thread"),
  llvm::cl::init(false), llvm::cl::Hidden);
 
+static llvm::cl::opt
+CompileCommands("compile-commands-dir",
+ llvm::cl::desc("Specify a path to look for compile_commands.json. If path is invalid, clangd will look in the current directory and parent paths of each source file.")); 
+
+
 int main(int argc, char *argv[]) {
   llvm::cl::ParseCommandLineOptions(argc, argv, "clangd");
 
   llvm::raw_ostream  = llvm::outs();
   llvm::raw_ostream  = llvm::errs();
   JSONOutput Out(Outs, Logs);
 
+  // If --compileCommands arg was invoked, check value and override default path.
+  namespace path = llvm::sys::path;
+  if (!llvm::sys::path::is_absolute(CompileCommands) || CompileCommands.empty())
+Logs << "Path specified for compilation database must be absolute. Verifying current folder instead.";
+
+  if (!llvm::sys::fs::exists(CompileCommands))
+Logs << "File does not exist. Verifying current folder instead.";
+
   // Change stdin to binary to not lose \r\n on windows.
   llvm::sys::ChangeStdinToBinary();
 
-  ClangdLSPServer LSPServer(Out, RunSynchronously);
+  ClangdLSPServer LSPServer(Out, RunSynchronously, CompileCommands);
   LSPServer.run(std::cin);
 }
Index: clangd/GlobalCompilationDatabase.h
===
--- clangd/GlobalCompilationDatabase.h
+++ clangd/GlobalCompilationDatabase.h
@@ -33,8 +33,9 @@
 public:
   virtual ~GlobalCompilationDatabase() = default;
 
-  virtual std::vector
+  virtual std::vector  
   getCompileCommands(PathRef File) = 0;
+  std::string CompileCommands;  
 
   /// FIXME(ibiryukov): add facilities to track changes to compilation flags of
   /// existing targets.
@@ -49,6 +50,7 @@
   getCompileCommands(PathRef File) override;
 
   void setExtraFlagsForFile(PathRef File, std::vector ExtraFlags);
+  tooling::CompilationDatabase *tryLoadDatabaseFromPath(PathRef File, std::string );
 
 private:
   tooling::CompilationDatabase *getCompilationDatabase(PathRef File);
Index: clangd/GlobalCompilationDatabase.cpp
===
--- clangd/GlobalCompilationDatabase.cpp
+++ clangd/GlobalCompilationDatabase.cpp
@@ -11,6 +11,16 @@
 #include "clang/Tooling/CompilationDatabase.h"
 #include "llvm/Support/FileSystem.h"
 #include "llvm/Support/Path.h"
+#include "llvm/ADT/Statistic.h"
+#include "llvm/ADT/StringExtras.h"
+#include "llvm/Support/CommandLine.h"
+#include "llvm/Support/Compiler.h"
+#include "llvm/Support/Debug.h"
+#include "llvm/Support/Format.h"
+#include "llvm/Support/ManagedStatic.h"
+#include "llvm/Support/Mutex.h"
+#include "llvm/Support/Timer.h"
+#include 

[PATCH] D37454: [coroutines] Make sure auto return type of await_resume is properly handled

2017-09-05 Thread Gor Nishanov via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL312565: [coroutines] Make sure auto return type of 
await_resume is properly handled (authored by GorNishanov).

Changed prior to commit:
  https://reviews.llvm.org/D37454?vs=113800=113894#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D37454

Files:
  cfe/trunk/lib/Sema/SemaCoroutine.cpp
  cfe/trunk/test/SemaCXX/coroutines.cpp


Index: cfe/trunk/lib/Sema/SemaCoroutine.cpp
===
--- cfe/trunk/lib/Sema/SemaCoroutine.cpp
+++ cfe/trunk/lib/Sema/SemaCoroutine.cpp
@@ -438,14 +438,14 @@
 //   - await-suspend is the expression e.await_suspend(h), which shall be
 // a prvalue of type void or bool.
 QualType RetType = AwaitSuspend->getCallReturnType(S.Context);
+
 // Experimental support for coroutine_handle returning await_suspend.
 if (Expr *TailCallSuspend = maybeTailCall(S, RetType, AwaitSuspend, Loc))
   Calls.Results[ACT::ACT_Suspend] = TailCallSuspend;
 else {
   // non-class prvalues always have cv-unqualified types
-  QualType AdjRetType = RetType.getUnqualifiedType();
   if (RetType->isReferenceType() ||
-  (AdjRetType != S.Context.BoolTy && AdjRetType != S.Context.VoidTy)) {
+  (!RetType->isBooleanType() && !RetType->isVoidType())) {
 S.Diag(AwaitSuspend->getCalleeDecl()->getLocation(),
diag::err_await_suspend_invalid_return_type)
 << RetType;
Index: cfe/trunk/test/SemaCXX/coroutines.cpp
===
--- cfe/trunk/test/SemaCXX/coroutines.cpp
+++ cfe/trunk/test/SemaCXX/coroutines.cpp
@@ -66,6 +66,12 @@
   void await_resume() {}
 };
 
+struct auto_await_suspend {
+  bool await_ready();
+  template  auto await_suspend(F) {}
+  void await_resume();
+};
+
 struct DummyVoidTag {};
 DummyVoidTag no_specialization() { // expected-error {{this function cannot be 
a coroutine: 'std::experimental::coroutine_traits' has no member 
named 'promise_type'}}
   co_await a;
@@ -159,6 +165,10 @@
   co_yield yield; // expected-error {{no member named 'await_ready' in 
'not_awaitable'}}
 }
 
+void check_auto_await_suspend() {
+  co_await auto_await_suspend{}; // Should compile successfully.
+}
+
 void coreturn(int n) {
   co_await a;
   if (n == 0)


Index: cfe/trunk/lib/Sema/SemaCoroutine.cpp
===
--- cfe/trunk/lib/Sema/SemaCoroutine.cpp
+++ cfe/trunk/lib/Sema/SemaCoroutine.cpp
@@ -438,14 +438,14 @@
 //   - await-suspend is the expression e.await_suspend(h), which shall be
 // a prvalue of type void or bool.
 QualType RetType = AwaitSuspend->getCallReturnType(S.Context);
+
 // Experimental support for coroutine_handle returning await_suspend.
 if (Expr *TailCallSuspend = maybeTailCall(S, RetType, AwaitSuspend, Loc))
   Calls.Results[ACT::ACT_Suspend] = TailCallSuspend;
 else {
   // non-class prvalues always have cv-unqualified types
-  QualType AdjRetType = RetType.getUnqualifiedType();
   if (RetType->isReferenceType() ||
-  (AdjRetType != S.Context.BoolTy && AdjRetType != S.Context.VoidTy)) {
+  (!RetType->isBooleanType() && !RetType->isVoidType())) {
 S.Diag(AwaitSuspend->getCalleeDecl()->getLocation(),
diag::err_await_suspend_invalid_return_type)
 << RetType;
Index: cfe/trunk/test/SemaCXX/coroutines.cpp
===
--- cfe/trunk/test/SemaCXX/coroutines.cpp
+++ cfe/trunk/test/SemaCXX/coroutines.cpp
@@ -66,6 +66,12 @@
   void await_resume() {}
 };
 
+struct auto_await_suspend {
+  bool await_ready();
+  template  auto await_suspend(F) {}
+  void await_resume();
+};
+
 struct DummyVoidTag {};
 DummyVoidTag no_specialization() { // expected-error {{this function cannot be a coroutine: 'std::experimental::coroutine_traits' has no member named 'promise_type'}}
   co_await a;
@@ -159,6 +165,10 @@
   co_yield yield; // expected-error {{no member named 'await_ready' in 'not_awaitable'}}
 }
 
+void check_auto_await_suspend() {
+  co_await auto_await_suspend{}; // Should compile successfully.
+}
+
 void coreturn(int n) {
   co_await a;
   if (n == 0)
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r312565 - [coroutines] Make sure auto return type of await_resume is properly handled

2017-09-05 Thread Gor Nishanov via cfe-commits
Author: gornishanov
Date: Tue Sep  5 12:31:52 2017
New Revision: 312565

URL: http://llvm.org/viewvc/llvm-project?rev=312565=rev
Log:
[coroutines] Make sure auto return type of await_resume is properly handled

Reviewers: rsmith, EricWF

Reviewed By: rsmith

Subscribers: javed.absar, cfe-commits

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

Modified:
cfe/trunk/lib/Sema/SemaCoroutine.cpp
cfe/trunk/test/SemaCXX/coroutines.cpp

Modified: cfe/trunk/lib/Sema/SemaCoroutine.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaCoroutine.cpp?rev=312565=312564=312565=diff
==
--- cfe/trunk/lib/Sema/SemaCoroutine.cpp (original)
+++ cfe/trunk/lib/Sema/SemaCoroutine.cpp Tue Sep  5 12:31:52 2017
@@ -438,14 +438,14 @@ static ReadySuspendResumeResult buildCoa
 //   - await-suspend is the expression e.await_suspend(h), which shall be
 // a prvalue of type void or bool.
 QualType RetType = AwaitSuspend->getCallReturnType(S.Context);
+
 // Experimental support for coroutine_handle returning await_suspend.
 if (Expr *TailCallSuspend = maybeTailCall(S, RetType, AwaitSuspend, Loc))
   Calls.Results[ACT::ACT_Suspend] = TailCallSuspend;
 else {
   // non-class prvalues always have cv-unqualified types
-  QualType AdjRetType = RetType.getUnqualifiedType();
   if (RetType->isReferenceType() ||
-  (AdjRetType != S.Context.BoolTy && AdjRetType != S.Context.VoidTy)) {
+  (!RetType->isBooleanType() && !RetType->isVoidType())) {
 S.Diag(AwaitSuspend->getCalleeDecl()->getLocation(),
diag::err_await_suspend_invalid_return_type)
 << RetType;

Modified: cfe/trunk/test/SemaCXX/coroutines.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/coroutines.cpp?rev=312565=312564=312565=diff
==
--- cfe/trunk/test/SemaCXX/coroutines.cpp (original)
+++ cfe/trunk/test/SemaCXX/coroutines.cpp Tue Sep  5 12:31:52 2017
@@ -66,6 +66,12 @@ struct suspend_never {
   void await_resume() {}
 };
 
+struct auto_await_suspend {
+  bool await_ready();
+  template  auto await_suspend(F) {}
+  void await_resume();
+};
+
 struct DummyVoidTag {};
 DummyVoidTag no_specialization() { // expected-error {{this function cannot be 
a coroutine: 'std::experimental::coroutine_traits' has no member 
named 'promise_type'}}
   co_await a;
@@ -159,6 +165,10 @@ void yield() {
   co_yield yield; // expected-error {{no member named 'await_ready' in 
'not_awaitable'}}
 }
 
+void check_auto_await_suspend() {
+  co_await auto_await_suspend{}; // Should compile successfully.
+}
+
 void coreturn(int n) {
   co_await a;
   if (n == 0)


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


[PATCH] D37454: [coroutines] Make sure auto return type of await_resume is properly handled

2017-09-05 Thread Gor Nishanov via Phabricator via cfe-commits
GorNishanov marked an inline comment as done.
GorNishanov added inline comments.



Comment at: test/SemaCXX/coroutines.cpp:169
+void check_auto_await_suspend() {
+  co_await auto_await_suspend{}; // OK
+}

javed.absar wrote:
> maybe change the comment to something more meaningful, or remove it.
Sure thing. I'll remove the comment.


https://reviews.llvm.org/D37454



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


[libcxxabi] r312553 - Creating release candidate final from release_500 branch

2017-09-05 Thread Hans Wennborg via cfe-commits
Author: hans
Date: Tue Sep  5 11:20:11 2017
New Revision: 312553

URL: http://llvm.org/viewvc/llvm-project?rev=312553=rev
Log:
Creating release candidate final from release_500 branch

Added:
libcxxabi/tags/RELEASE_500/final/
  - copied from r312552, libcxxabi/branches/release_50/

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


[libunwind] r312559 - Creating release candidate final from release_500 branch

2017-09-05 Thread Hans Wennborg via cfe-commits
Author: hans
Date: Tue Sep  5 11:20:18 2017
New Revision: 312559

URL: http://llvm.org/viewvc/llvm-project?rev=312559=rev
Log:
Creating release candidate final from release_500 branch

Added:
libunwind/tags/RELEASE_500/final/   (props changed)
  - copied from r312558, libunwind/branches/release_50/

Propchange: libunwind/tags/RELEASE_500/final/
--
svn:mergeinfo = /libunwind/trunk:308871,309147


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


[libcxx] r312552 - Creating release candidate final from release_500 branch

2017-09-05 Thread Hans Wennborg via cfe-commits
Author: hans
Date: Tue Sep  5 11:20:11 2017
New Revision: 312552

URL: http://llvm.org/viewvc/llvm-project?rev=312552=rev
Log:
Creating release candidate final from release_500 branch

Added:
libcxx/tags/RELEASE_500/final/   (props changed)
  - copied from r312551, libcxx/branches/release_50/

Propchange: libcxx/tags/RELEASE_500/final/
--
--- svn:mergeinfo (added)
+++ svn:mergeinfo Tue Sep  5 11:20:11 2017
@@ -0,0 +1,2 @@
+/libcxx/branches/apple:136569-137939
+/libcxx/trunk:309296,309307,309474,309838,309851,309917,309920


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


[PATCH] D37042: Teach clang to tolerate the 'p = nullptr + n' idiom used by glibc

2017-09-05 Thread Andy Kaylor via Phabricator via cfe-commits
andrew.w.kaylor added a comment.

Ping.


https://reviews.llvm.org/D37042



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


[PATCH] D37390: [diagtool] Change default tree behavior to print only flags

2017-09-05 Thread Jonas Devlieghere via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL312546: [diagtool] Change default tree behavior to print 
only flags (authored by JDevlieghere).

Changed prior to commit:
  https://reviews.llvm.org/D37390?vs=113737=113885#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D37390

Files:
  cfe/trunk/test/Misc/warning-flags-tree.c
  cfe/trunk/tools/diagtool/TreeView.cpp

Index: cfe/trunk/tools/diagtool/TreeView.cpp
===
--- cfe/trunk/tools/diagtool/TreeView.cpp
+++ cfe/trunk/tools/diagtool/TreeView.cpp
@@ -32,10 +32,10 @@
 public:
   llvm::raw_ostream 
   const bool ShowColors;
-  bool FlagsOnly;
+  bool Internal;
 
   TreePrinter(llvm::raw_ostream )
-  : out(out), ShowColors(hasColors(out)), FlagsOnly(false) {}
+  : out(out), ShowColors(hasColors(out)), Internal(false) {}
 
   void setColor(llvm::raw_ostream::Colors Color) {
 if (ShowColors)
@@ -54,19 +54,37 @@
 return Diags.isIgnored(DiagID, SourceLocation());
   }
 
+  static bool enabledByDefault(const GroupRecord ) {
+for (const DiagnosticRecord  : Group.diagnostics()) {
+  if (isIgnored(DR.DiagID))
+return false;
+}
+
+for (const GroupRecord  : Group.subgroups()) {
+  if (!enabledByDefault(GR))
+return false;
+}
+
+return true;
+  }
+
   void printGroup(const GroupRecord , unsigned Indent = 0) {
 out.indent(Indent * 2);
 
-setColor(llvm::raw_ostream::YELLOW);
+if (enabledByDefault(Group))
+  setColor(llvm::raw_ostream::GREEN);
+else
+  setColor(llvm::raw_ostream::YELLOW);
+
 out << "-W" << Group.getName() << "\n";
 resetColor();
 
 ++Indent;
 for (const GroupRecord  : Group.subgroups()) {
   printGroup(GR, Indent);
 }
 
-if (!FlagsOnly) {
+if (Internal) {
   for (const DiagnosticRecord  : Group.diagnostics()) {
 if (ShowColors && !isIgnored(DR.DiagID))
   setColor(llvm::raw_ostream::GREEN);
@@ -132,16 +150,16 @@
 };
 
 static void printUsage() {
-  llvm::errs() << "Usage: diagtool tree [--flags-only] []\n";
+  llvm::errs() << "Usage: diagtool tree [--internal] []\n";
 }
 
 int TreeView::run(unsigned int argc, char **argv, llvm::raw_ostream ) {
   // First check our one flag (--flags-only).
-  bool FlagsOnly = false;
+  bool Internal = false;
   if (argc > 0) {
 StringRef FirstArg(*argv);
-if (FirstArg.equals("--flags-only")) {
-  FlagsOnly = true;
+if (FirstArg.equals("--internal")) {
+  Internal = true;
   --argc;
   ++argv;
 }
@@ -168,7 +186,7 @@
   }
 
   TreePrinter TP(out);
-  TP.FlagsOnly = FlagsOnly;
+  TP.Internal = Internal;
   TP.showKey();
   return ShowAll ? TP.showAll() : TP.showGroup(RootGroup);
 }
Index: cfe/trunk/test/Misc/warning-flags-tree.c
===
--- cfe/trunk/test/Misc/warning-flags-tree.c
+++ cfe/trunk/test/Misc/warning-flags-tree.c
@@ -1,6 +1,6 @@
-// RUN: diagtool tree | FileCheck -strict-whitespace %s
-// RUN: diagtool tree -Weverything | FileCheck -strict-whitespace %s
-// RUN: diagtool tree everything | FileCheck -strict-whitespace %s
+// RUN: diagtool tree --internal | FileCheck -strict-whitespace %s
+// RUN: diagtool tree --internal -Weverything | FileCheck -strict-whitespace %s
+// RUN: diagtool tree --internal everything | FileCheck -strict-whitespace %s
 //
 // These three ways of running diagtool tree are the same:
 // they produce a tree for every top-level diagnostic flag.
@@ -29,8 +29,7 @@
 
 // RUN: not diagtool tree -Wthis-is-not-a-valid-flag
 
-
-// RUN: diagtool tree -Wgnu | FileCheck -strict-whitespace -check-prefix CHECK-GNU %s
+// RUN: diagtool tree --internal -Wgnu | FileCheck -strict-whitespace -check-prefix CHECK-GNU %s
 // CHECK-GNU: -Wgnu
 // CHECK-GNU:   -Wgnu-designator
 // CHECK-GNU: ext_gnu_array_range
@@ -40,7 +39,7 @@
 // CHECK-GNU: ext_vla
 // There are more GNU extensions but we don't need to check them all.
 
-// RUN: diagtool tree --flags-only -Wgnu | FileCheck -check-prefix CHECK-FLAGS-ONLY %s
+// RUN: diagtool tree -Wgnu | FileCheck -check-prefix CHECK-FLAGS-ONLY %s
 // CHECK-FLAGS-ONLY: -Wgnu
 // CHECK-FLAGS-ONLY:   -Wgnu-designator
 // CHECK-FLAGS-ONLY-NOT: ext_gnu_array_range
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r312545 - [NFC] Loop modernization in diagtool

2017-09-05 Thread Jonas Devlieghere via cfe-commits
Author: jdevlieghere
Date: Tue Sep  5 11:04:34 2017
New Revision: 312545

URL: http://llvm.org/viewvc/llvm-project?rev=312545=rev
Log:
[NFC] Loop modernization in diagtool

Precommit for https://reviews.llvm.org/D37390

Modified:
cfe/trunk/tools/diagtool/DiagnosticNames.cpp
cfe/trunk/tools/diagtool/DiagnosticNames.h
cfe/trunk/tools/diagtool/ListWarnings.cpp
cfe/trunk/tools/diagtool/ShowEnabledWarnings.cpp
cfe/trunk/tools/diagtool/TreeView.cpp

Modified: cfe/trunk/tools/diagtool/DiagnosticNames.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/diagtool/DiagnosticNames.cpp?rev=312545=312544=312545=diff
==
--- cfe/trunk/tools/diagtool/DiagnosticNames.cpp (original)
+++ cfe/trunk/tools/diagtool/DiagnosticNames.cpp Tue Sep  5 11:04:34 2017
@@ -84,6 +84,11 @@ GroupRecord::subgroup_iterator GroupReco
   return nullptr;
 }
 
+llvm::iterator_range
+GroupRecord::subgroups() const {
+  return llvm::make_range(subgroup_begin(), subgroup_end());
+}
+
 GroupRecord::diagnostics_iterator GroupRecord::diagnostics_begin() const {
   return DiagArrays + Members;
 }
@@ -92,6 +97,11 @@ GroupRecord::diagnostics_iterator GroupR
   return nullptr;
 }
 
+llvm::iterator_range
+GroupRecord::diagnostics() const {
+  return llvm::make_range(diagnostics_begin(), diagnostics_end());
+}
+
 llvm::ArrayRef diagtool::getDiagnosticGroups() {
   return llvm::makeArrayRef(OptionTable);
 }

Modified: cfe/trunk/tools/diagtool/DiagnosticNames.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/diagtool/DiagnosticNames.h?rev=312545=312544=312545=diff
==
--- cfe/trunk/tools/diagtool/DiagnosticNames.h (original)
+++ cfe/trunk/tools/diagtool/DiagnosticNames.h Tue Sep  5 11:04:34 2017
@@ -20,7 +20,7 @@ namespace diagtool {
 const char *NameStr;
 short DiagID;
 uint8_t NameLen;
-
+
 llvm::StringRef getName() const {
   return llvm::StringRef(NameStr, NameLen);
 }
@@ -80,7 +80,7 @@ namespace diagtool {
   bool operator==(group_iterator ) const {
 return CurrentID == Other.CurrentID;
   }
-  
+
   bool operator!=(group_iterator ) const {
 return CurrentID != Other.CurrentID;
   }
@@ -89,10 +89,12 @@ namespace diagtool {
 typedef group_iterator subgroup_iterator;
 subgroup_iterator subgroup_begin() const;
 subgroup_iterator subgroup_end() const;
+llvm::iterator_range subgroups() const;
 
 typedef group_iterator diagnostics_iterator;
 diagnostics_iterator diagnostics_begin() const;
 diagnostics_iterator diagnostics_end() const;
+llvm::iterator_range diagnostics() const;
 
 bool operator<(llvm::StringRef Other) const {
   return getName() < Other;

Modified: cfe/trunk/tools/diagtool/ListWarnings.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/diagtool/ListWarnings.cpp?rev=312545=312544=312545=diff
==
--- cfe/trunk/tools/diagtool/ListWarnings.cpp (original)
+++ cfe/trunk/tools/diagtool/ListWarnings.cpp Tue Sep  5 11:04:34 2017
@@ -23,7 +23,7 @@
 DEF_DIAGTOOL("list-warnings",
  "List warnings and their corresponding flags",
  ListWarnings)
-  
+
 using namespace clang;
 using namespace diagtool;
 
@@ -31,20 +31,19 @@ namespace {
 struct Entry {
   llvm::StringRef DiagName;
   llvm::StringRef Flag;
-  
+
   Entry(llvm::StringRef diagN, llvm::StringRef flag)
 : DiagName(diagN), Flag(flag) {}
-  
+
   bool operator<(const Entry ) const { return DiagName < x.DiagName; }
 };
 }
 
 static void printEntries(std::vector , llvm::raw_ostream ) {
-  for (std::vector::iterator it = entries.begin(), ei = entries.end();
-   it != ei; ++it) {
-out << "  " << it->DiagName;
-if (!it->Flag.empty())
-  out << " [-W" << it->Flag << "]";
+  for (const Entry  : entries) {
+out << "  " << E.DiagName;
+if (!E.Flag.empty())
+  out << " [-W" << E.Flag << "]";
 out << '\n';
   }
 }
@@ -52,23 +51,18 @@ static void printEntries(std::vector Flagged, Unflagged;
   llvm::StringMap flagHistogram;
-  
-  ArrayRef AllDiagnostics = getBuiltinDiagnosticsByName();
 
-  for (ArrayRef::iterator di = AllDiagnostics.begin(),
-de = AllDiagnostics.end();
-   di != de; ++di) {
-unsigned diagID = di->DiagID;
-
+  for (const DiagnosticRecord  : getBuiltinDiagnosticsByName()) {
+const unsigned diagID = DR.DiagID;
+
 if (DiagnosticIDs::isBuiltinNote(diagID))
   continue;
-
+
 if (!DiagnosticIDs::isBuiltinWarningOrExtension(diagID))
   continue;
-  
-Entry entry(di->getName(),
-DiagnosticIDs::getWarningOptionForDiag(diagID));
-
+
+Entry entry(DR.getName(), DiagnosticIDs::getWarningOptionForDiag(diagID));
+
 if (entry.Flag.empty())
   

r312546 - [diagtool] Change default tree behavior to print only flags

2017-09-05 Thread Jonas Devlieghere via cfe-commits
Author: jdevlieghere
Date: Tue Sep  5 11:04:40 2017
New Revision: 312546

URL: http://llvm.org/viewvc/llvm-project?rev=312546=rev
Log:
[diagtool] Change default tree behavior to print only flags

This patch changes the default behavior of `diagtool tree` to only
display warning flags and not the internal warnings flags. The latter is
an implementation detail of the compiler and usually not what the users
wants.

Furthermore, flags that are enabled by default are now also printed in
green. Originally, this was only the case for the diagnostic names.

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

Modified:
cfe/trunk/test/Misc/warning-flags-tree.c
cfe/trunk/tools/diagtool/TreeView.cpp

Modified: cfe/trunk/test/Misc/warning-flags-tree.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Misc/warning-flags-tree.c?rev=312546=312545=312546=diff
==
--- cfe/trunk/test/Misc/warning-flags-tree.c (original)
+++ cfe/trunk/test/Misc/warning-flags-tree.c Tue Sep  5 11:04:40 2017
@@ -1,6 +1,6 @@
-// RUN: diagtool tree | FileCheck -strict-whitespace %s
-// RUN: diagtool tree -Weverything | FileCheck -strict-whitespace %s
-// RUN: diagtool tree everything | FileCheck -strict-whitespace %s
+// RUN: diagtool tree --internal | FileCheck -strict-whitespace %s
+// RUN: diagtool tree --internal -Weverything | FileCheck -strict-whitespace %s
+// RUN: diagtool tree --internal everything | FileCheck -strict-whitespace %s
 //
 // These three ways of running diagtool tree are the same:
 // they produce a tree for every top-level diagnostic flag.
@@ -29,8 +29,7 @@
 
 // RUN: not diagtool tree -Wthis-is-not-a-valid-flag
 
-
-// RUN: diagtool tree -Wgnu | FileCheck -strict-whitespace -check-prefix 
CHECK-GNU %s
+// RUN: diagtool tree --internal -Wgnu | FileCheck -strict-whitespace 
-check-prefix CHECK-GNU %s
 // CHECK-GNU: -Wgnu
 // CHECK-GNU:   -Wgnu-designator
 // CHECK-GNU: ext_gnu_array_range
@@ -40,7 +39,7 @@
 // CHECK-GNU: ext_vla
 // There are more GNU extensions but we don't need to check them all.
 
-// RUN: diagtool tree --flags-only -Wgnu | FileCheck -check-prefix 
CHECK-FLAGS-ONLY %s
+// RUN: diagtool tree -Wgnu | FileCheck -check-prefix CHECK-FLAGS-ONLY %s
 // CHECK-FLAGS-ONLY: -Wgnu
 // CHECK-FLAGS-ONLY:   -Wgnu-designator
 // CHECK-FLAGS-ONLY-NOT: ext_gnu_array_range

Modified: cfe/trunk/tools/diagtool/TreeView.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/diagtool/TreeView.cpp?rev=312546=312545=312546=diff
==
--- cfe/trunk/tools/diagtool/TreeView.cpp (original)
+++ cfe/trunk/tools/diagtool/TreeView.cpp Tue Sep  5 11:04:40 2017
@@ -32,10 +32,10 @@ class TreePrinter {
 public:
   llvm::raw_ostream 
   const bool ShowColors;
-  bool FlagsOnly;
+  bool Internal;
 
   TreePrinter(llvm::raw_ostream )
-  : out(out), ShowColors(hasColors(out)), FlagsOnly(false) {}
+  : out(out), ShowColors(hasColors(out)), Internal(false) {}
 
   void setColor(llvm::raw_ostream::Colors Color) {
 if (ShowColors)
@@ -54,10 +54,28 @@ public:
 return Diags.isIgnored(DiagID, SourceLocation());
   }
 
+  static bool enabledByDefault(const GroupRecord ) {
+for (const DiagnosticRecord  : Group.diagnostics()) {
+  if (isIgnored(DR.DiagID))
+return false;
+}
+
+for (const GroupRecord  : Group.subgroups()) {
+  if (!enabledByDefault(GR))
+return false;
+}
+
+return true;
+  }
+
   void printGroup(const GroupRecord , unsigned Indent = 0) {
 out.indent(Indent * 2);
 
-setColor(llvm::raw_ostream::YELLOW);
+if (enabledByDefault(Group))
+  setColor(llvm::raw_ostream::GREEN);
+else
+  setColor(llvm::raw_ostream::YELLOW);
+
 out << "-W" << Group.getName() << "\n";
 resetColor();
 
@@ -66,7 +84,7 @@ public:
   printGroup(GR, Indent);
 }
 
-if (!FlagsOnly) {
+if (Internal) {
   for (const DiagnosticRecord  : Group.diagnostics()) {
 if (ShowColors && !isIgnored(DR.DiagID))
   setColor(llvm::raw_ostream::GREEN);
@@ -132,16 +150,16 @@ public:
 };
 
 static void printUsage() {
-  llvm::errs() << "Usage: diagtool tree [--flags-only] []\n";
+  llvm::errs() << "Usage: diagtool tree [--internal] []\n";
 }
 
 int TreeView::run(unsigned int argc, char **argv, llvm::raw_ostream ) {
   // First check our one flag (--flags-only).
-  bool FlagsOnly = false;
+  bool Internal = false;
   if (argc > 0) {
 StringRef FirstArg(*argv);
-if (FirstArg.equals("--flags-only")) {
-  FlagsOnly = true;
+if (FirstArg.equals("--internal")) {
+  Internal = true;
   --argc;
   ++argv;
 }
@@ -168,7 +186,7 @@ int TreeView::run(unsigned int argc, cha
   }
 
   TreePrinter TP(out);
-  TP.FlagsOnly = FlagsOnly;
+  TP.Internal = Internal;
   TP.showKey();
   return ShowAll ? TP.showAll() : TP.showGroup(RootGroup);
 }



r312542 - [Preprocessor] Correct internal token parsing of newline characters in CRLF

2017-09-05 Thread Erich Keane via cfe-commits
Author: erichkeane
Date: Tue Sep  5 10:32:36 2017
New Revision: 312542

URL: http://llvm.org/viewvc/llvm-project?rev=312542=rev
Log:
[Preprocessor] Correct internal token parsing of newline characters in CRLF

Correct implementation:  Apparently I managed in r311683 to submit the wrong
version of the patch for this, so I'm correcting it now.

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

Modified:
cfe/trunk/lib/Lex/Lexer.cpp

Modified: cfe/trunk/lib/Lex/Lexer.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/Lexer.cpp?rev=312542=312541=312542=diff
==
--- cfe/trunk/lib/Lex/Lexer.cpp (original)
+++ cfe/trunk/lib/Lex/Lexer.cpp Tue Sep  5 10:32:36 2017
@@ -3071,10 +3071,11 @@ LexNextToken:
 Kind = tok::unknown;
 break;
   
-  case '\n':
   case '\r':
-if (CurPtr[0] != Char && (CurPtr[0] == '\n' || CurPtr[0] == '\r'))
+if (CurPtr[0] == '\n')
   Char = getAndAdvanceChar(CurPtr, Result);
+LLVM_FALLTHROUGH;
+  case '\n':
 // If we are inside a preprocessor directive and we see the end of line,
 // we know we are done with the directive, so return an EOD token.
 if (ParsingPreprocessorDirective) {


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


[PATCH] D36475: [analyzer] Add "create_sink" annotation support to MagentaHandleChecker

2017-09-05 Thread Devin Coughlin via Phabricator via cfe-commits
dcoughlin added a comment.

I'm a bit surprised that this is needed for unit tests. Aren't unit tests 
supposed to clean up their own state? Leaking a scarce resource in one unit 
test can cause another unit test to fail, which can be hard to track down. Or 
is this for deliberately testing a scenario where a resource is leaked? If 
you're deliberately testing a leaking scenario, it seems to me that using 
#ifndef __clang_analyzer__ would probably be an easier suppression mechanism 
for the test author  to understand and maintain.

Can you elaborate on why you're running the analyzer on units tests and how 
reports from the analyzer on unit tests are used? I think it would be helpful 
for us to understand your work flow.

Also, in general, my feeling is the exposing the internal mechanisms of the 
analyzer (here, the notion of a sink) in an attribute is not good for users. 
Ideally, attributes should be used to describe the behavior of code that they 
annotate. This means that they also serve as documentation for the user and not 
just as an ad hoc mechanism to communicate with the analyzer.


https://reviews.llvm.org/D36475



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


[PATCH] D36251: [analyzer] Suppress warning when bug path contains noreturn function or return from main in MagentaHandleChecker

2017-09-05 Thread Devin Coughlin via Phabricator via cfe-commits
dcoughlin added a comment.

I'm worried about doing this for main(). I think many people would find it 
surprising if analyzing main() were to behave differently than other functions. 
I'm particularly worried because I think it is quite common to create a small 
test program with only main() to understand the behavior of the analyzer.


https://reviews.llvm.org/D36251



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


[PATCH] D33826: [clang-tidy] avoid pointer cast to more strict alignment check

2017-09-05 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

Have you run this check over any large code bases to see what the quality of 
the diagnostics are?




Comment at: docs/clang-tidy/checks/cert-exp36-c.rst:9
+ 
+This check is the same as `-Wcast-align`, except it checks for 
`reinterpret_cast` as well.
+

Can you update the tests to include the ones from -Wcast-align 
(llvm\tools\clang\test\Sema\warn-cast-align.c) to make sure those are properly 
triggered by this check?


Repository:
  rL LLVM

https://reviews.llvm.org/D33826



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


[PATCH] D37196: [Clang] Bug 32352 - Provide a way for OptimizationRemarkEmitter::allowExtraAnalysis to check if (specific) remarks are enabled

2017-09-05 Thread Vivek Pandya via Phabricator via cfe-commits
vivekvpandya updated this revision to Diff 113879.
vivekvpandya added a comment.

Clang-formated


https://reviews.llvm.org/D37196

Files:
  lib/CodeGen/CodeGenAction.cpp


Index: lib/CodeGen/CodeGenAction.cpp
===
--- lib/CodeGen/CodeGenAction.cpp
+++ lib/CodeGen/CodeGenAction.cpp
@@ -224,10 +224,10 @@
   void *OldContext = Ctx.getInlineAsmDiagnosticContext();
   Ctx.setInlineAsmDiagnosticHandler(InlineAsmDiagHandler, this);
 
-  LLVMContext::DiagnosticHandlerTy OldDiagnosticHandler =
-  Ctx.getDiagnosticHandler();
-  void *OldDiagnosticContext = Ctx.getDiagnosticContext();
-  Ctx.setDiagnosticHandler(DiagnosticHandler, this);
+  //LLVMContext::DiagnosticHandlerTy OldDiagnosticHandler =
+  //Ctx.getDiagnosticHandler();
+ // void *OldDiagnosticContext = Ctx.getDiagnosticContext();
+ // Ctx.setDiagnosticHandler(DiagnosticHandler, this);
   Ctx.setDiagnosticsHotnessRequested(CodeGenOpts.DiagnosticsWithHotness);
   if (CodeGenOpts.DiagnosticsHotnessThreshold != 0)
 Ctx.setDiagnosticsHotnessThreshold(
@@ -264,7 +264,7 @@
 
   Ctx.setInlineAsmDiagnosticHandler(OldHandler, OldContext);
 
-  Ctx.setDiagnosticHandler(OldDiagnosticHandler, OldDiagnosticContext);
+  //Ctx.setDiagnosticHandler(OldDiagnosticHandler, OldDiagnosticContext);
 
   if (OptRecordFile)
 OptRecordFile->keep();
@@ -756,6 +756,32 @@
 }
 #undef ComputeDiagID
 
+class ClangDiagnosticHandler final : public DiagnosticHandler {
+public:
+  ClangDiagnosticHandler(const CodeGenOptions , void *DiagContext)
+  : DiagnosticHandler(DiagContext), CodeGenOpts(CGOpts) {}
+
+  bool handleDiagnostics(const DiagnosticInfo ) override {
+((BackendConsumer *)DiagnosticContext)->DiagnosticHandlerImpl(DI);
+return true;
+  }
+  bool isAnalysisRemarkEnable(const std::string ) {
+return (CodeGenOpts.OptimizationRemarkAnalysisPattern &&
+CodeGenOpts.OptimizationRemarkAnalysisPattern->match(PassName));
+  }
+  bool isMissedOptRemarkEnable(const std::string ) {
+return (CodeGenOpts.OptimizationRemarkMissedPattern &&
+CodeGenOpts.OptimizationRemarkMissedPattern->match(PassName));
+  }
+  bool isPassedOptRemarkEnable(const std::string ) {
+return (CodeGenOpts.OptimizationRemarkPattern &&
+CodeGenOpts.OptimizationRemarkPattern->match(PassName));
+  }
+
+private:
+  const CodeGenOptions 
+};
+
 CodeGenAction::CodeGenAction(unsigned _Act, LLVMContext *_VMContext)
 : Act(_Act), VMContext(_VMContext ? _VMContext : new LLVMContext),
   OwnsVMContext(!_VMContext) {}
@@ -853,7 +879,8 @@
   CI.getLangOpts(), CI.getFrontendOpts().ShowTimers, InFile,
   std::move(LinkModules), std::move(OS), *VMContext, CoverageInfo));
   BEConsumer = Result.get();
-
+  VMContext->setDiagnosticHandler(llvm::make_unique(
+  CI.getCodeGenOpts(), Result.get()));
   // Enable generating macro debug info only when debug info is not disabled 
and
   // also macro debug info is enabled.
   if (CI.getCodeGenOpts().getDebugInfo() != codegenoptions::NoDebugInfo &&


Index: lib/CodeGen/CodeGenAction.cpp
===
--- lib/CodeGen/CodeGenAction.cpp
+++ lib/CodeGen/CodeGenAction.cpp
@@ -224,10 +224,10 @@
   void *OldContext = Ctx.getInlineAsmDiagnosticContext();
   Ctx.setInlineAsmDiagnosticHandler(InlineAsmDiagHandler, this);
 
-  LLVMContext::DiagnosticHandlerTy OldDiagnosticHandler =
-  Ctx.getDiagnosticHandler();
-  void *OldDiagnosticContext = Ctx.getDiagnosticContext();
-  Ctx.setDiagnosticHandler(DiagnosticHandler, this);
+  //LLVMContext::DiagnosticHandlerTy OldDiagnosticHandler =
+  //Ctx.getDiagnosticHandler();
+ // void *OldDiagnosticContext = Ctx.getDiagnosticContext();
+ // Ctx.setDiagnosticHandler(DiagnosticHandler, this);
   Ctx.setDiagnosticsHotnessRequested(CodeGenOpts.DiagnosticsWithHotness);
   if (CodeGenOpts.DiagnosticsHotnessThreshold != 0)
 Ctx.setDiagnosticsHotnessThreshold(
@@ -264,7 +264,7 @@
 
   Ctx.setInlineAsmDiagnosticHandler(OldHandler, OldContext);
 
-  Ctx.setDiagnosticHandler(OldDiagnosticHandler, OldDiagnosticContext);
+  //Ctx.setDiagnosticHandler(OldDiagnosticHandler, OldDiagnosticContext);
 
   if (OptRecordFile)
 OptRecordFile->keep();
@@ -756,6 +756,32 @@
 }
 #undef ComputeDiagID
 
+class ClangDiagnosticHandler final : public DiagnosticHandler {
+public:
+  ClangDiagnosticHandler(const CodeGenOptions , void *DiagContext)
+  : DiagnosticHandler(DiagContext), CodeGenOpts(CGOpts) {}
+
+  bool handleDiagnostics(const DiagnosticInfo ) override {
+((BackendConsumer *)DiagnosticContext)->DiagnosticHandlerImpl(DI);
+return true;
+  }
+  bool isAnalysisRemarkEnable(const std::string ) {
+return (CodeGenOpts.OptimizationRemarkAnalysisPattern &&
+

[PATCH] D37448: Fix cast assertion on MS inline assembly with vector spills (PR34021)

2017-09-05 Thread Reid Kleckner via Phabricator via cfe-commits
rnk added a comment.

I think this is a reasonable stop-gap fix since the code isn't trying to return 
EAX:EDX or XMM0 from the inline asm blob. This affects any function that 
contains inline asm and returns a vector, which is potentially a lot of stuff.




Comment at: test/CodeGen/pr34021.c:2
+// RUN: %clang_cc1 -fms-extensions %s -triple=i686-unknown-unknown -emit-llvm 
-o -
+// RUN: %clang_cc1 -fms-extensions %s -triple=x86_64-unknown-unknown 
-emit-llvm -o -
+// REQUIRES: asserts

Please FileCheck the IR. We should see a pattern like this:
```
define <4 x float> @rep()
  %retval = alloca <4 x float>
  call i64 inlineasm sideeffect {{.*}}
  store {{.*}}, <4 x float>* %retval
  %v = load {{.*}}, <4 x float>* %res
  store <4 x float> %v, <4 x float>* %retval
  %rv = load <4 x float>* %retval
  ret <4 x float> %rv
```

That IR pattern makes it clear that the store of the asm output is immediately 
killed by the store of `res` to `retval`.


Repository:
  rL LLVM

https://reviews.llvm.org/D37448



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


[PATCH] D37474: [PCH] Allow VFS to be used for tests that generate PCH files

2017-09-05 Thread Cameron via Phabricator via cfe-commits
cameron314 added a comment.

I suppose we could do the overlay manually in all the tests that need it; I 
guess it depends on what the goal of the VFS support is. To my mind, it doesn't 
make sense that a file is placed in the RealFS in the first place if a VFS is 
used, but this is quite entrenched in the current design and difficult to 
change. In which case, I would argue that parsing a file with a preamble and a 
VFS should not give a cryptic error without an explicit overlay, but rather 
"just work". But I agree my current patch is a little crude in that it allows 
access to the entire RealFS via the VFS.

I could change the automatic overlay to *only* support access to the generated 
PCH file, similar to how the `FilteredFileSystem` you've pointed out works, but 
for a single file only. Would that be acceptable?


https://reviews.llvm.org/D37474



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


[PATCH] D37428: Debug info: Fixed faulty debug locations for attributed statements

2017-09-05 Thread David Blaikie via Phabricator via cfe-commits
dblaikie accepted this revision.
dblaikie added a comment.
This revision is now accepted and ready to land.

OK, sounds good - thanks :)


https://reviews.llvm.org/D37428



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


[PATCH] D33825: [clang-tidy] signal handler must be plain old function check

2017-09-05 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

Aside from a few small nits, this looks reasonable. Have you run it over any 
large code bases that use signals to test the quality of the check?




Comment at: docs/clang-tidy/checks/cert-msc54-cpp.rst:23
+extern "C" void cpp_signal_handler(int sig) {
+  // warning: do not use C++ representations in signal handlers
+  throw "error message";

The warning text should match the actual warning.



Comment at: 
test/clang-tidy/cert-signal-handler-must-be-plain-old-function.cpp:56-57
+  // CHECK-MESSAGES: :[[@LINE-1]]:17: warning: do not call functions with C++ 
constructs in signal handlers [cert-msc54-cpp]
+  // CHECK-MESSAGES: :[[@LINE-11]]:3: note: function called here
+  // CHECK-MESSAGES: :[[@LINE-23]]:3: note: C++ construct used here
+  recursive_function();

Can you move these to be closer to where the actual note appears? It makes it 
easier to ensure that the diagnostic appears on the proper line.


Repository:
  rL LLVM

https://reviews.llvm.org/D33825



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


[PATCH] D37428: Debug info: Fixed faulty debug locations for attributed statements

2017-09-05 Thread Karl-Johan Karlsson via Phabricator via cfe-commits
Ka-Ka added a comment.

In https://reviews.llvm.org/D37428#861140, @dblaikie wrote:

> Not sure what you mean by "avoid emitting unnecessary stop points" - do you 
> have a test case for that?


In my previous patch you could end up doing two calls to EmitStopPoint() for 
the same statement. In the previous patch I added a EmitStopPoint() in the 
method EmitAttributedStmt(), but if you took the default clause in the switch 
statement in the same method you could end up executing another EmitStopPoint() 
in EmitStmt().

The new patch do not have the issue with executing EmitStopPoint() twice for 
the same statement. I think generally that the new patch is more robust 
solution.


https://reviews.llvm.org/D37428



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


[PATCH] D37428: Debug info: Fixed faulty debug locations for attributed statements

2017-09-05 Thread David Blaikie via Phabricator via cfe-commits
dblaikie added a comment.

Not sure what you mean by "avoid emitting unnecessary stop points" - do you 
have a test case for that?


https://reviews.llvm.org/D37428



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


[PATCH] D37478: [analyzer] Implement pointer arithmetic on constants

2017-09-05 Thread Rafael Stahl via Phabricator via cfe-commits
r.stahl created this revision.
Herald added a subscriber: eraman.

The "Multiplicand" variable in SimpleSValBuilder::evalBinOpLN was always 
initialized to zero, causing all pointer arithmetic on constant values to be 
no-ops.

This fixes two FIXMEs in existing tests. The added tests were all failing 
before this change.


https://reviews.llvm.org/D37478

Files:
  lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp
  test/Analysis/explain-svals.cpp
  test/Analysis/inlining/inline-defensive-checks.c
  test/Analysis/pointer-arithmetic.c


Index: test/Analysis/pointer-arithmetic.c
===
--- test/Analysis/pointer-arithmetic.c
+++ test/Analysis/pointer-arithmetic.c
@@ -0,0 +1,28 @@
+// RUN: %clang_analyze_cc1 -analyzer-checker=core -verify %s
+
+int test1() {
+  int *p = (int *)sizeof(int);
+  p -= 1;
+  return *p; // expected-warning {{Dereference of null pointer}}
+}
+
+int test2() {
+  int *p = (int *)sizeof(int);
+  p -= 2;
+  p += 1;
+  return *p; // expected-warning {{Dereference of null pointer}}
+}
+
+int test3() {
+  int *p = (int *)sizeof(int);
+  p++;
+  p--;
+  p--;
+  return *p; // expected-warning {{Dereference of null pointer}}
+}
+
+int test4() {
+  int *p = 0;
+  p += 1;
+  return *p; // no-warning
+}
Index: test/Analysis/inlining/inline-defensive-checks.c
===
--- test/Analysis/inlining/inline-defensive-checks.c
+++ test/Analysis/inlining/inline-defensive-checks.c
@@ -159,8 +159,7 @@
 void idcTrackZeroValueThroughUnaryPointerOperatorsWithOffset2(struct S *s) {
   idc(s);
   int *x = &(s->f2) - 1;
-  // FIXME: Should not warn.
-  *x = 7; // expected-warning{{Dereference of null pointer}}
+  *x = 7; // no-warning
 }
 
 void idcTrackZeroValueThroughUnaryPointerOperatorsWithAssignment(struct S *s) {
Index: test/Analysis/explain-svals.cpp
===
--- test/Analysis/explain-svals.cpp
+++ test/Analysis/explain-svals.cpp
@@ -59,8 +59,7 @@
   clang_analyzer_explain([5].y[3]); // expected-warning-re^pointer to 
element of type 'int' with index 3 of field 'y' of base object 'S::S3' inside 
element of type 'struct S::S2' with index 5 of field 's2' of parameter 's'$
   if (!s.s2[7].x) {
 clang_analyzer_explain(s.s2[7].x); // expected-warning-re^concrete 
memory address '0'$
-// FIXME: we need to be explaining '1' rather than '0' here; not explainer 
bug.
-clang_analyzer_explain(s.s2[7].x + 1); // expected-warning-re^concrete 
memory address '0'$
+clang_analyzer_explain(s.s2[7].x + 1); // expected-warning-re^concrete 
memory address '4'$
   }
 }
 
Index: lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp
===
--- lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp
+++ lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp
@@ -935,6 +935,8 @@
 
   // Offset the increment by the pointer size.
   llvm::APSInt Multiplicand(rightI.getBitWidth(), /* isUnsigned */ true);
+  QualType PteeTy = 
resultTy.getTypePtr()->castAs()->getPointeeType();
+  Multiplicand = getContext().getTypeSizeInChars(PteeTy).getQuantity();
   rightI *= Multiplicand;
 
   // Compute the adjusted pointer.


Index: test/Analysis/pointer-arithmetic.c
===
--- test/Analysis/pointer-arithmetic.c
+++ test/Analysis/pointer-arithmetic.c
@@ -0,0 +1,28 @@
+// RUN: %clang_analyze_cc1 -analyzer-checker=core -verify %s
+
+int test1() {
+  int *p = (int *)sizeof(int);
+  p -= 1;
+  return *p; // expected-warning {{Dereference of null pointer}}
+}
+
+int test2() {
+  int *p = (int *)sizeof(int);
+  p -= 2;
+  p += 1;
+  return *p; // expected-warning {{Dereference of null pointer}}
+}
+
+int test3() {
+  int *p = (int *)sizeof(int);
+  p++;
+  p--;
+  p--;
+  return *p; // expected-warning {{Dereference of null pointer}}
+}
+
+int test4() {
+  int *p = 0;
+  p += 1;
+  return *p; // no-warning
+}
Index: test/Analysis/inlining/inline-defensive-checks.c
===
--- test/Analysis/inlining/inline-defensive-checks.c
+++ test/Analysis/inlining/inline-defensive-checks.c
@@ -159,8 +159,7 @@
 void idcTrackZeroValueThroughUnaryPointerOperatorsWithOffset2(struct S *s) {
   idc(s);
   int *x = &(s->f2) - 1;
-  // FIXME: Should not warn.
-  *x = 7; // expected-warning{{Dereference of null pointer}}
+  *x = 7; // no-warning
 }
 
 void idcTrackZeroValueThroughUnaryPointerOperatorsWithAssignment(struct S *s) {
Index: test/Analysis/explain-svals.cpp
===
--- test/Analysis/explain-svals.cpp
+++ test/Analysis/explain-svals.cpp
@@ -59,8 +59,7 @@
   clang_analyzer_explain([5].y[3]); // expected-warning-re^pointer to element of type 'int' with index 3 of field 'y' of base object 'S::S3' inside element 

[PATCH] D37448: Fix cast assertion on MS inline assembly with vector spills (PR34021)

2017-09-05 Thread Erich Keane via Phabricator via cfe-commits
erichkeane added a comment.

Ah, I seem to remember that the problem here is that we don't know whether this 
value should be signed or unsigned at this point, so it could be 
CreateZExtOrTrunc OR CreateSignExtOrTrunc?  However, there is no information as 
to whether the integer is signed here as far as I remember...


Repository:
  rL LLVM

https://reviews.llvm.org/D37448



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


[PATCH] D37448: Fix cast assertion on MS inline assembly with vector spills (PR34021)

2017-09-05 Thread Erich Keane via Phabricator via cfe-commits
erichkeane added a comment.

In https://reviews.llvm.org/D37448#861069, @RKSimon wrote:

> In https://reviews.llvm.org/D37448#861019, @erichkeane wrote:
>
> > I apologize for the lack of detail for this comment, but I didn't seem to 
> > capture this at the time.  When I investigated this initially, I came up 
> > with this solution and it was insufficient.  I don't remember WHAT this 
> > ends up not fixing however.
>
>
> @erichkeane OK, are you in a position to take on this bug? Either 
> commandeering this patch or I abandon it and you start your own?


I'm not sure I have time for it unfortunately.  It IS on my personal backlog, I 
just haven't had time lately.  Has this affected someone else (besides my 
company's internal tests), or become more important lately?


Repository:
  rL LLVM

https://reviews.llvm.org/D37448



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


[PATCH] D37474: [PCH] Allow VFS to be used for tests that generate PCH files

2017-09-05 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov added a comment.

Could we fix this in tests instead by providing an overlay over `RealFS` there 
instead of doing that in `ASTUnit`?

If I'm passing `vfs::FileSystem`, I specifically **do not want** any file 
accesses to silently go through `RealFS`, ignoring the `vfs::FileSystem` that I 
passed.

We do overlays in `clangd` and we also have a `vfs::FileSystem` implementation 
that only reads certain `WhitelistedDirs` from `RealFS` to ensure we don't read 
other files from `RealFS`.
See 
https://reviews.llvm.org/diffusion/L/browse/clang-tools-extra/trunk/unittests/clangd/ClangdTests.cpp;312537$34.


https://reviews.llvm.org/D37474



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


[PATCH] D37448: Fix cast assertion on MS inline assembly with vector spills (PR34021)

2017-09-05 Thread Simon Pilgrim via Phabricator via cfe-commits
RKSimon added a comment.

In https://reviews.llvm.org/D37448#861019, @erichkeane wrote:

> I apologize for the lack of detail for this comment, but I didn't seem to 
> capture this at the time.  When I investigated this initially, I came up with 
> this solution and it was insufficient.  I don't remember WHAT this ends up 
> not fixing however.


@erichkeane OK, are you in a position to take on this bug? Either commandeering 
this patch or I abandon it and you start your own?


Repository:
  rL LLVM

https://reviews.llvm.org/D37448



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


r312536 - [clang-format] Fix lines=all case in clang-format.py

2017-09-05 Thread Krasimir Georgiev via cfe-commits
Author: krasimir
Date: Tue Sep  5 06:58:53 2017
New Revision: 312536

URL: http://llvm.org/viewvc/llvm-project?rev=312536=rev
Log:
[clang-format] Fix lines=all case in clang-format.py

Modified:
cfe/trunk/tools/clang-format/clang-format.py

Modified: cfe/trunk/tools/clang-format/clang-format.py
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/clang-format/clang-format.py?rev=312536=312535=312536=diff
==
--- cfe/trunk/tools/clang-format/clang-format.py (original)
+++ cfe/trunk/tools/clang-format/clang-format.py Tue Sep  5 06:58:53 2017
@@ -92,7 +92,7 @@ def main():
 
   # Call formatter.
   command = [binary, '-style', style, '-cursor', str(cursor)]
-  if lines != 'all':
+  if lines != ['-lines', 'all']:
 command += lines
   if fallback_style:
 command.extend(['-fallback-style', fallback_style])


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


r312535 - add the option IndentPPDirectives to the release notes. Landed in r312125

2017-09-05 Thread Sylvestre Ledru via cfe-commits
Author: sylvestre
Date: Tue Sep  5 06:56:40 2017
New Revision: 312535

URL: http://llvm.org/viewvc/llvm-project?rev=312535=rev
Log:
add the option IndentPPDirectives to the release notes. Landed in r312125

Modified:
cfe/trunk/docs/ReleaseNotes.rst

Modified: cfe/trunk/docs/ReleaseNotes.rst
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/ReleaseNotes.rst?rev=312535=312534=312535=diff
==
--- cfe/trunk/docs/ReleaseNotes.rst (original)
+++ cfe/trunk/docs/ReleaseNotes.rst Tue Sep  5 06:56:40 2017
@@ -74,7 +74,7 @@ Improvements to Clang's diagnostics
 Non-comprehensive list of changes in this release
 -
 
-- Bitrig OS was merged back into OpenBSD, so Bitrig support has been 
+- Bitrig OS was merged back into OpenBSD, so Bitrig support has been
   removed from Clang/LLVM.
 
 New Compiler Flags
@@ -190,7 +190,20 @@ There are two main patterns affected by
 clang-format
 
 
-...
+* Option *IndentPPDirectives* added to indent preprocessor directives on
+  conditionals.
+
+  +--+--+
+  | Before   | After|
+  +==+==+
+  |  .. code-block:: c++ | .. code-block:: c++  |
+  |  |  |
+  |#if FOO   |   #if FOO|
+  |#if BAR   |   #  if BAR  |
+  |#include |   #include  |
+  |#endif|   #  endif   |
+  |#endif|   #endif |
+  +--+--+
 
 * Option -verbose added to the command line.
   Shows the list of processed files.


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


[PATCH] D37448: Fix cast assertion on MS inline assembly with vector spills (PR34021)

2017-09-05 Thread Erich Keane via Phabricator via cfe-commits
erichkeane added a comment.

I apologize for the lack of detail for this comment, but I didn't seem to 
capture this at the time.  When I investigated this initially, I came up with 
this solution and it was insufficient.  I don't remember WHAT this ends up not 
fixing however.

When discussing it with @rnk we decided that (according to my notes):

"so, addReturnRegisterOutputs needs to look at the LLVM return type, and choose 
between EAX:EDX for integer / struct return types,
ST0 for small FP types, and XMM0/YMM0 etc for vectors/big FP types"

The issue is more that the *TargetInfo::addReturnRegisterOutputs doesn't 
properly configure things, it simply works with integers. It needs to be 
extended to work with int/struct types, as well as vector/FP types.


Repository:
  rL LLVM

https://reviews.llvm.org/D37448



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


[PATCH] D20338: [PCH] Fixed overridden files always invalidating preamble even when unchanged

2017-09-05 Thread Cameron via Phabricator via cfe-commits
cameron314 abandoned this revision.
cameron314 added a comment.

This patch is obsolete. While waiting over a year for a review, somebody else 
came across the same fix (for a different manifestation of the same bug) in 
https://reviews.llvm.org/D27810 and managed to get it through. I think my test 
case and supporting changes are still useful, however, so I've submitted that 
separately in https://reviews.llvm.org/D37474.


https://reviews.llvm.org/D20338



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


[PATCH] D37474: [PCH] Allow VFS to be used for tests that generate PCH files

2017-09-05 Thread Cameron via Phabricator via cfe-commits
cameron314 created this revision.
Herald added a subscriber: mgorny.

When using a virtual file-system (VFS) and a preamble file (PCH) is generated, 
it is generated on-disk in the real file-system instead of in the VFS (which I 
guess makes sense, since the VFS is read-only). However, when subsequently 
reading the generated PCH, the frontend passes through the VFS it has been 
given -- resulting in an error and a failed parse (since the VFS doesn't 
contain the PCH; the real filesystem does).

This patch fixes that by detecting when a VFS is being used for a parse that 
needs to work with a PCH file, and creating an overlay VFS that includes the 
real file-system underneath. Since the PCH is hard-coded to always be on the 
real file-system, I believe this is the cleanest approach.

This allows tests to be written which make use of both PCH files and a VFS, 
like the one I've included here.

Note: This was originally part of the code to test the bug fixed in 
https://reviews.llvm.org/D20338, but while languishing in review it has since 
been fixed by somebody else in https://reviews.llvm.org/D27810. However, I feel 
it's still important to be able to test the frontend preamble code while at the 
same time making use of a VFS, so I've rebased that part of the patch (and my 
test to go with it).


https://reviews.llvm.org/D37474

Files:
  lib/Frontend/ASTUnit.cpp
  unittests/Frontend/CMakeLists.txt
  unittests/Frontend/PchPreambleTest.cpp

Index: unittests/Frontend/PchPreambleTest.cpp
===
--- /dev/null
+++ unittests/Frontend/PchPreambleTest.cpp
@@ -0,0 +1,156 @@
+//-- unittests/Frontend/PchPreambleTest.cpp - FrontendAction tests ---//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#include "clang/Frontend/ASTUnit.h"
+#include "clang/Frontend/CompilerInvocation.h"
+#include "clang/Frontend/CompilerInstance.h"
+#include "clang/Frontend/FrontendActions.h"
+#include "clang/Frontend/FrontendOptions.h"
+#include "clang/Lex/PreprocessorOptions.h"
+#include "clang/Basic/Diagnostic.h"
+#include "clang/Basic/FileManager.h"
+#include "llvm/Support/FileSystem.h"
+#include "llvm/Support/MemoryBuffer.h"
+#include "llvm/Support/Path.h"
+#include "gtest/gtest.h"
+
+using namespace llvm;
+using namespace clang;
+
+namespace {
+
+class ReadCountingInMemoryFileSystem : public vfs::InMemoryFileSystem
+{
+  std::map ReadCounts;
+
+public:
+  ErrorOr openFileForRead(const Twine ) override
+  {
+SmallVector PathVec;
+Path.toVector(PathVec);
+llvm::sys::path::remove_dots(PathVec, true);
+++ReadCounts[std::string(PathVec.begin(), PathVec.end())];
+return InMemoryFileSystem::openFileForRead(Path);
+  }
+
+  unsigned GetReadCount(const Twine ) const
+  {
+auto it = ReadCounts.find(Path.str());
+return it == ReadCounts.end() ? 0 : it->second;
+  }
+};
+
+class PchPreambleTest : public ::testing::Test {
+  IntrusiveRefCntPtr VFS;
+  StringMap RemappedFiles;
+  std::shared_ptr PCHContainerOpts;
+  FileSystemOptions FSOpts;
+
+public:
+  void SetUp() override {
+VFS = new ReadCountingInMemoryFileSystem();
+// We need the working directory to be set to something absolute,
+// otherwise it ends up being inadvertently set to the current
+// working directory in the real file system due to a series of
+// unfortunate conditions interacting badly.
+// What's more, this path *must* be absolute on all (real)
+// filesystems, so just '/' won't work (e.g. on Win32).
+VFS->setCurrentWorkingDirectory("//./");
+  }
+
+  void TearDown() override {
+  }
+
+  void AddFile(const std::string , const std::string ) {
+::time_t now;
+::time();
+VFS->addFile(Filename, now, MemoryBuffer::getMemBufferCopy(Contents, Filename));
+  }
+
+  void RemapFile(const std::string , const std::string ) {
+RemappedFiles[Filename] = Contents;
+  }
+
+  std::unique_ptr ParseAST(const std::string ) {
+PCHContainerOpts = std::make_shared();
+std::shared_ptr CI(new CompilerInvocation);
+CI->getFrontendOpts().Inputs.push_back(
+  FrontendInputFile(EntryFile, FrontendOptions::getInputKindForExtension(
+llvm::sys::path::extension(EntryFile).substr(1;
+
+CI->getTargetOpts().Triple = "i386-unknown-linux-gnu";
+
+CI->getPreprocessorOpts().RemappedFileBuffers = GetRemappedFiles();
+
+PreprocessorOptions  = CI->getPreprocessorOpts();
+PPOpts.RemappedFilesKeepOriginalName = true;
+
+IntrusiveRefCntPtr
+  Diags(CompilerInstance::createDiagnostics(new DiagnosticOptions, new DiagnosticConsumer));
+
+FileManager *FileMgr = new FileManager(FSOpts, VFS);
+
+std::unique_ptr AST = ASTUnit::LoadFromCompilerInvocation(
+   

[PATCH] D31140: [LLVMbugs] [Bug 18710] Only generate .ARM.exidx and .ARM.extab when needed in EHABI

2017-09-05 Thread Christian Bruel via Phabricator via cfe-commits
chrib updated this revision to Diff 113846.
chrib added a comment.
Herald added a subscriber: kristof.beyls.

Rebase and cleanup NeedsUnwindTable for be variants.


https://reviews.llvm.org/D31140

Files:
  lib/CodeGen/CodeGenModule.cpp
  lib/CodeGen/CodeGenModule.h


Index: lib/CodeGen/CodeGenModule.h
===
--- lib/CodeGen/CodeGenModule.h
+++ lib/CodeGen/CodeGenModule.h
@@ -1334,6 +1334,11 @@
   void ConstructDefaultFnAttrList(StringRef Name, bool HasOptnone,
   bool AttrOnCallSite,
   llvm::AttrBuilder );
+
+  /// Check whether the attribute UWTable must be set to emit the unwind table
+  /// for exceptions
+  bool NeedsUnwindTable();
+
 };
 
 }  // end namespace CodeGen
Index: lib/CodeGen/CodeGenModule.cpp
===
--- lib/CodeGen/CodeGenModule.cpp
+++ lib/CodeGen/CodeGenModule.cpp
@@ -914,13 +914,32 @@
   return true;
 }
 
+// This function needs an unwind table
+bool CodeGenModule::NeedsUnwindTable() {
+  if (CodeGenOpts.UnwindTables)
+return true;
+
+  // xxx checkarm eabi needs to emit the nowind attribute.
+  // implement function ins ARM.cpp
+  const llvm::Triple T = Context.getTargetInfo().getTriple();
+  if (hasUnwindExceptions (LangOpts)
+  && (T.isARM() || T.isThumb ())
+  && (T.getEnvironment() == llvm::Triple::EABI))
+  return true;
+
+  return false;
+}
+
 void CodeGenModule::SetLLVMFunctionAttributesForDefinition(const Decl *D,
llvm::Function *F) {
   llvm::AttrBuilder B;
 
-  if (CodeGenOpts.UnwindTables)
+  // Set the attribute if the user requests it or if the language requiers it.
+  if (NeedsUnwindTable())
 B.addAttribute(llvm::Attribute::UWTable);
 
+  // If the module doesn't support exceptions the function cannot throw.
+  // We can have a nothrow function even if unwind tables are required.
   if (!hasUnwindExceptions(LangOpts))
 B.addAttribute(llvm::Attribute::NoUnwind);
 


Index: lib/CodeGen/CodeGenModule.h
===
--- lib/CodeGen/CodeGenModule.h
+++ lib/CodeGen/CodeGenModule.h
@@ -1334,6 +1334,11 @@
   void ConstructDefaultFnAttrList(StringRef Name, bool HasOptnone,
   bool AttrOnCallSite,
   llvm::AttrBuilder );
+
+  /// Check whether the attribute UWTable must be set to emit the unwind table
+  /// for exceptions
+  bool NeedsUnwindTable();
+
 };
 
 }  // end namespace CodeGen
Index: lib/CodeGen/CodeGenModule.cpp
===
--- lib/CodeGen/CodeGenModule.cpp
+++ lib/CodeGen/CodeGenModule.cpp
@@ -914,13 +914,32 @@
   return true;
 }
 
+// This function needs an unwind table
+bool CodeGenModule::NeedsUnwindTable() {
+  if (CodeGenOpts.UnwindTables)
+return true;
+
+  // xxx checkarm eabi needs to emit the nowind attribute.
+  // implement function ins ARM.cpp
+  const llvm::Triple T = Context.getTargetInfo().getTriple();
+  if (hasUnwindExceptions (LangOpts)
+  && (T.isARM() || T.isThumb ())
+  && (T.getEnvironment() == llvm::Triple::EABI))
+  return true;
+
+  return false;
+}
+
 void CodeGenModule::SetLLVMFunctionAttributesForDefinition(const Decl *D,
llvm::Function *F) {
   llvm::AttrBuilder B;
 
-  if (CodeGenOpts.UnwindTables)
+  // Set the attribute if the user requests it or if the language requiers it.
+  if (NeedsUnwindTable())
 B.addAttribute(llvm::Attribute::UWTable);
 
+  // If the module doesn't support exceptions the function cannot throw.
+  // We can have a nothrow function even if unwind tables are required.
   if (!hasUnwindExceptions(LangOpts))
 B.addAttribute(llvm::Attribute::NoUnwind);
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D37470: [analyzer] Handle ObjC messages conservatively in CallDescription

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

The users of CallDescription no longer need to make sure that the called 
function is a C function. This makes the API usage easier and it conservatively 
will never match ObjC Messages. In the future, this construct might be extended 
to support overloading, ctors, dtors, messages.


Repository:
  rL LLVM

https://reviews.llvm.org/D37470

Files:
  lib/StaticAnalyzer/Core/CallEvent.cpp


Index: lib/StaticAnalyzer/Core/CallEvent.cpp
===
--- lib/StaticAnalyzer/Core/CallEvent.cpp
+++ lib/StaticAnalyzer/Core/CallEvent.cpp
@@ -211,7 +211,9 @@
 }
 
 bool CallEvent::isCalled(const CallDescription ) const {
-  assert(getKind() != CE_ObjCMessage && "Obj-C methods are not supported");
+  // FIXME: Add ObjC Message support.
+  if (getKind() == CE_ObjCMessage)
+return false;
   if (!CD.IsLookupDone) {
 CD.IsLookupDone = true;
 CD.II = 
()->getStateManager().getContext().Idents.get(CD.FuncName);


Index: lib/StaticAnalyzer/Core/CallEvent.cpp
===
--- lib/StaticAnalyzer/Core/CallEvent.cpp
+++ lib/StaticAnalyzer/Core/CallEvent.cpp
@@ -211,7 +211,9 @@
 }
 
 bool CallEvent::isCalled(const CallDescription ) const {
-  assert(getKind() != CE_ObjCMessage && "Obj-C methods are not supported");
+  // FIXME: Add ObjC Message support.
+  if (getKind() == CE_ObjCMessage)
+return false;
   if (!CD.IsLookupDone) {
 CD.IsLookupDone = true;
 CD.II = ()->getStateManager().getContext().Idents.get(CD.FuncName);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D37465: [Bash-autocomplete] Fix crash when invoking --autocomplete without value.

2017-09-05 Thread Raphael Isemann via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL312533: [Bash-autocomplete] Fix crash when invoking 
--autocomplete without value. (authored by teemperor).

Changed prior to commit:
  https://reviews.llvm.org/D37465?vs=113829=113842#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D37465

Files:
  cfe/trunk/lib/Driver/Driver.cpp
  cfe/trunk/test/Driver/autocomplete.c


Index: cfe/trunk/test/Driver/autocomplete.c
===
--- cfe/trunk/test/Driver/autocomplete.c
+++ cfe/trunk/test/Driver/autocomplete.c
@@ -2,6 +2,19 @@
 // autocompletion. You may have to update tests in this file when you
 // 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=-fsyn | FileCheck %s -check-prefix=FSYN
 // FSYN: -fsyntax-only
 // RUN: %clang --autocomplete=-std= | FileCheck %s -check-prefix=STD
Index: cfe/trunk/lib/Driver/Driver.cpp
===
--- cfe/trunk/lib/Driver/Driver.cpp
+++ cfe/trunk/lib/Driver/Driver.cpp
@@ -1165,12 +1165,10 @@
   unsigned short DisableFlags =
   options::NoDriverOption | options::Unsupported | options::Ignored;
   // We want to show cc1-only options only when clang is invoked as "clang
-  // -cc1".
-  // When clang is invoked as "clang -cc1", we add "#" to the beginning of an
-  // --autocomplete
-  // option so that the clang driver can distinguish whether it is requested to
-  // show cc1-only options or not.
-  if (PassedFlags[0] == '#') {
+  // -cc1". When clang is invoked as "clang -cc1", we add "#" to the beginning
+  // of an --autocomplete  option so that the clang driver can distinguish
+  // whether it is requested to show cc1-only options or not.
+  if (PassedFlags.size() > 0 && PassedFlags[0] == '#') {
 DisableFlags &= ~options::NoDriverOption;
 PassedFlags = PassedFlags.substr(1);
   }


Index: cfe/trunk/test/Driver/autocomplete.c
===
--- cfe/trunk/test/Driver/autocomplete.c
+++ cfe/trunk/test/Driver/autocomplete.c
@@ -2,6 +2,19 @@
 // autocompletion. You may have to update tests in this file when you
 // 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=-fsyn | FileCheck %s -check-prefix=FSYN
 // FSYN: -fsyntax-only
 // RUN: %clang --autocomplete=-std= | FileCheck %s -check-prefix=STD
Index: cfe/trunk/lib/Driver/Driver.cpp
===
--- cfe/trunk/lib/Driver/Driver.cpp
+++ cfe/trunk/lib/Driver/Driver.cpp
@@ -1165,12 +1165,10 @@
   unsigned short DisableFlags =
   options::NoDriverOption | options::Unsupported | options::Ignored;
   // We want to show cc1-only options only when clang is invoked as "clang
-  // -cc1".
-  // When clang is invoked as "clang -cc1", we add "#" to the beginning of an
-  // --autocomplete
-  // option so that the clang driver can distinguish whether it is requested to
-  // show cc1-only options or not.
-  if (PassedFlags[0] == '#') {
+  // -cc1". When clang is invoked as "clang -cc1", we add "#" to the beginning
+  // of an --autocomplete  option so that the clang driver can distinguish
+  // whether it is requested to show cc1-only options or not.
+  if (PassedFlags.size() > 0 && PassedFlags[0] == '#') {
 DisableFlags &= ~options::NoDriverOption;
 PassedFlags = PassedFlags.substr(1);
   }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r312533 - [Bash-autocomplete] Fix crash when invoking --autocomplete without value.

2017-09-05 Thread Raphael Isemann via cfe-commits
Author: teemperor
Date: Tue Sep  5 05:41:00 2017
New Revision: 312533

URL: http://llvm.org/viewvc/llvm-project?rev=312533=rev
Log:
[Bash-autocomplete] Fix crash when invoking --autocomplete without value.

Summary:
Currently clang segfaults when invoked with `clang --autocomplete=`.
This patch adds the necessary boundary checks and some tests for corner cases 
like this.

Reviewers: yamaguchi

Reviewed By: yamaguchi

Subscribers: cfe-commits

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

Modified:
cfe/trunk/lib/Driver/Driver.cpp
cfe/trunk/test/Driver/autocomplete.c

Modified: cfe/trunk/lib/Driver/Driver.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Driver.cpp?rev=312533=312532=312533=diff
==
--- cfe/trunk/lib/Driver/Driver.cpp (original)
+++ cfe/trunk/lib/Driver/Driver.cpp Tue Sep  5 05:41:00 2017
@@ -1165,12 +1165,10 @@ void Driver::handleAutocompletions(Strin
   unsigned short DisableFlags =
   options::NoDriverOption | options::Unsupported | options::Ignored;
   // We want to show cc1-only options only when clang is invoked as "clang
-  // -cc1".
-  // When clang is invoked as "clang -cc1", we add "#" to the beginning of an
-  // --autocomplete
-  // option so that the clang driver can distinguish whether it is requested to
-  // show cc1-only options or not.
-  if (PassedFlags[0] == '#') {
+  // -cc1". When clang is invoked as "clang -cc1", we add "#" to the beginning
+  // of an --autocomplete  option so that the clang driver can distinguish
+  // whether it is requested to show cc1-only options or not.
+  if (PassedFlags.size() > 0 && PassedFlags[0] == '#') {
 DisableFlags &= ~options::NoDriverOption;
 PassedFlags = PassedFlags.substr(1);
   }

Modified: cfe/trunk/test/Driver/autocomplete.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/autocomplete.c?rev=312533=312532=312533=diff
==
--- cfe/trunk/test/Driver/autocomplete.c (original)
+++ cfe/trunk/test/Driver/autocomplete.c Tue Sep  5 05:41:00 2017
@@ -2,6 +2,19 @@
 // autocompletion. You may have to update tests in this file when you
 // 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=-fsyn | FileCheck %s -check-prefix=FSYN
 // FSYN: -fsyntax-only
 // RUN: %clang --autocomplete=-std= | FileCheck %s -check-prefix=STD


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


[PATCH] D37138: Make run-clang-tidy compatible with Python 3.x

2017-09-05 Thread Kevin Funk via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL312532: Make run-clang-tidy compatible with Python 3.x 
(authored by kfunk).

Changed prior to commit:
  https://reviews.llvm.org/D37138?vs=112677=113841#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D37138

Files:
  clang-tools-extra/trunk/clang-tidy/tool/run-clang-tidy.py


Index: clang-tools-extra/trunk/clang-tidy/tool/run-clang-tidy.py
===
--- clang-tools-extra/trunk/clang-tidy/tool/run-clang-tidy.py
+++ clang-tools-extra/trunk/clang-tidy/tool/run-clang-tidy.py
@@ -35,12 +35,12 @@
 """
 
 from __future__ import print_function
+
 import argparse
 import glob
 import json
 import multiprocessing
 import os
-import Queue
 import re
 import shutil
 import subprocess
@@ -50,6 +50,12 @@
 import traceback
 import yaml
 
+is_py2 = sys.version[0] == '2'
+
+if is_py2:
+import Queue as queue
+else:
+import queue as queue
 
 def find_compilation_database(path):
   """Adjusts the directory until a compilation database is found."""
@@ -233,20 +239,20 @@
 
   try:
 # Spin up a bunch of tidy-launching threads.
-queue = Queue.Queue(max_task)
+task_queue = queue.Queue(max_task)
 for _ in range(max_task):
   t = threading.Thread(target=run_tidy,
-   args=(args, tmpdir, build_path, queue))
+   args=(args, tmpdir, build_path, task_queue))
   t.daemon = True
   t.start()
 
 # Fill the queue with files.
 for name in files:
   if file_name_re.search(name):
-queue.put(name)
+task_queue.put(name)
 
 # Wait for all threads to be done.
-queue.join()
+task_queue.join()
 
   except KeyboardInterrupt:
 # This is a sad hack. Unfortunately subprocess goes


Index: clang-tools-extra/trunk/clang-tidy/tool/run-clang-tidy.py
===
--- clang-tools-extra/trunk/clang-tidy/tool/run-clang-tidy.py
+++ clang-tools-extra/trunk/clang-tidy/tool/run-clang-tidy.py
@@ -35,12 +35,12 @@
 """
 
 from __future__ import print_function
+
 import argparse
 import glob
 import json
 import multiprocessing
 import os
-import Queue
 import re
 import shutil
 import subprocess
@@ -50,6 +50,12 @@
 import traceback
 import yaml
 
+is_py2 = sys.version[0] == '2'
+
+if is_py2:
+import Queue as queue
+else:
+import queue as queue
 
 def find_compilation_database(path):
   """Adjusts the directory until a compilation database is found."""
@@ -233,20 +239,20 @@
 
   try:
 # Spin up a bunch of tidy-launching threads.
-queue = Queue.Queue(max_task)
+task_queue = queue.Queue(max_task)
 for _ in range(max_task):
   t = threading.Thread(target=run_tidy,
-   args=(args, tmpdir, build_path, queue))
+   args=(args, tmpdir, build_path, task_queue))
   t.daemon = True
   t.start()
 
 # Fill the queue with files.
 for name in files:
   if file_name_re.search(name):
-queue.put(name)
+task_queue.put(name)
 
 # Wait for all threads to be done.
-queue.join()
+task_queue.join()
 
   except KeyboardInterrupt:
 # This is a sad hack. Unfortunately subprocess goes
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] r312532 - Make run-clang-tidy compatible with Python 3.x

2017-09-05 Thread Kevin Funk via cfe-commits
Author: kfunk
Date: Tue Sep  5 05:36:33 2017
New Revision: 312532

URL: http://llvm.org/viewvc/llvm-project?rev=312532=rev
Log:
Make run-clang-tidy compatible with Python 3.x

Reviewers: alexfh

Reviewed By: alexfh

Subscribers: cfe-commits, JDevlieghere

Tags: #clang-tools-extra

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

Change-Id: I89a95d1e082e566e7e64c2a5ca4123c543e6b1be

Modified:
clang-tools-extra/trunk/clang-tidy/tool/run-clang-tidy.py

Modified: clang-tools-extra/trunk/clang-tidy/tool/run-clang-tidy.py
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/tool/run-clang-tidy.py?rev=312532=312531=312532=diff
==
--- clang-tools-extra/trunk/clang-tidy/tool/run-clang-tidy.py (original)
+++ clang-tools-extra/trunk/clang-tidy/tool/run-clang-tidy.py Tue Sep  5 
05:36:33 2017
@@ -35,12 +35,12 @@ http://clang.llvm.org/docs/HowToSetupToo
 """
 
 from __future__ import print_function
+
 import argparse
 import glob
 import json
 import multiprocessing
 import os
-import Queue
 import re
 import shutil
 import subprocess
@@ -50,6 +50,12 @@ import threading
 import traceback
 import yaml
 
+is_py2 = sys.version[0] == '2'
+
+if is_py2:
+import Queue as queue
+else:
+import queue as queue
 
 def find_compilation_database(path):
   """Adjusts the directory until a compilation database is found."""
@@ -233,20 +239,20 @@ def main():
 
   try:
 # Spin up a bunch of tidy-launching threads.
-queue = Queue.Queue(max_task)
+task_queue = queue.Queue(max_task)
 for _ in range(max_task):
   t = threading.Thread(target=run_tidy,
-   args=(args, tmpdir, build_path, queue))
+   args=(args, tmpdir, build_path, task_queue))
   t.daemon = True
   t.start()
 
 # Fill the queue with files.
 for name in files:
   if file_name_re.search(name):
-queue.put(name)
+task_queue.put(name)
 
 # Wait for all threads to be done.
-queue.join()
+task_queue.join()
 
   except KeyboardInterrupt:
 # This is a sad hack. Unfortunately subprocess goes


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


[PATCH] D37437: [analyzer] Fix some checker's output plist not containing the checker name

2017-09-05 Thread Gábor Horváth via Phabricator via cfe-commits
xazax.hun added a comment.

In https://reviews.llvm.org/D37437#860311, @NoQ wrote:

> Cool. Thanks!
>
> > In the future probably it would be better to alter the signature of the 
> > checkers' constructor to set the name in the constructor so it is possible 
> > to create the BugType eagerly.
>
> Still, should we add an assertion so that we could be sure that every bug 
> type contains a checker name?


Sure! I added the assert and discovered lots of other checks that had the same 
problem. I also discovered some other bugs, e.g.: when a checker was emitting 
diagnostic even without being turned on or the wrong name is emitted to the 
plist.




Comment at: test/Analysis/malloc.c:1723
 
-char *dupstrWarn(const char *s) {
-  const int len = strlen(s);

This test is deleted because the corresponding checker is not even turned on 
for this file and this warning should not be emitted at all. Emitting this 
warning with the settings above was a bug. 


https://reviews.llvm.org/D37437



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


[PATCH] D37468: [libc++] Redirect strftime_l to the locale-ignorant strftime on mingw

2017-09-05 Thread Martin Storsjö via Phabricator via cfe-commits
mstorsjo created this revision.

_strftime_l is only available in the numbered msvcrt versions (starting from 
msvcr80.dll). In the default configuration, mingw targets the unversioned 
msvcrt.dll - and there, _strftime_l is not available (not even on windows 10).

If __MSVCRT_VERSION__ is set to a higher value (indicating a non-default target 
and wanting to link to msvcrXX.dll), use the correct function.


https://reviews.llvm.org/D37468

Files:
  include/support/win32/locale_win32.h


Index: include/support/win32/locale_win32.h
===
--- include/support/win32/locale_win32.h
+++ include/support/win32/locale_win32.h
@@ -100,7 +100,11 @@
 #define iswxdigit_l _iswxdigit_l
 #define towupper_l _towupper_l
 #define towlower_l _towlower_l
+#if defined(__MINGW32__) && __MSVCRT_VERSION__ < 0x0800
+#define strftime_l( __s, __l, __f, __tm, __loc ) strftime( __s, __l, __f, __tm 
)
+#else
 #define strftime_l _strftime_l
+#endif
 #define sscanf_l( __s, __l, __f, ...) _sscanf_l( __s, __f, __l, __VA_ARGS__ )
 #define vsscanf_l( __s, __l, __f, ...) _sscanf_l( __s, __f, __l, __VA_ARGS__ )
 #define sprintf_l( __s, __l, __f, ... ) _sprintf_l( __s, __f, __l, __VA_ARGS__ 
)


Index: include/support/win32/locale_win32.h
===
--- include/support/win32/locale_win32.h
+++ include/support/win32/locale_win32.h
@@ -100,7 +100,11 @@
 #define iswxdigit_l _iswxdigit_l
 #define towupper_l _towupper_l
 #define towlower_l _towlower_l
+#if defined(__MINGW32__) && __MSVCRT_VERSION__ < 0x0800
+#define strftime_l( __s, __l, __f, __tm, __loc ) strftime( __s, __l, __f, __tm )
+#else
 #define strftime_l _strftime_l
+#endif
 #define sscanf_l( __s, __l, __f, ...) _sscanf_l( __s, __f, __l, __VA_ARGS__ )
 #define vsscanf_l( __s, __l, __f, ...) _sscanf_l( __s, __f, __l, __VA_ARGS__ )
 #define sprintf_l( __s, __l, __f, ... ) _sprintf_l( __s, __f, __l, __VA_ARGS__ )
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D37437: [analyzer] Fix some checker's output plist not containing the checker name

2017-09-05 Thread Gábor Horváth via Phabricator via cfe-commits
xazax.hun updated this revision to Diff 113837.
xazax.hun retitled this revision from "[analyzer] Fix SimpleStreamChecker's 
output plist not containing the checker name" to "[analyzer] Fix some checker's 
output plist not containing the checker name".
xazax.hun edited the summary of this revision.
xazax.hun added a comment.

- Fix more checkers
- Minor style fixes along the way
- Added an assert to prevent such errors in the future


https://reviews.llvm.org/D37437

Files:
  include/clang/StaticAnalyzer/Core/BugReporter/BugType.h
  lib/StaticAnalyzer/Checkers/BlockInCriticalSectionChecker.cpp
  lib/StaticAnalyzer/Checkers/CStringChecker.cpp
  lib/StaticAnalyzer/Checkers/CheckObjCDealloc.cpp
  lib/StaticAnalyzer/Checkers/IteratorChecker.cpp
  lib/StaticAnalyzer/Checkers/LocalizationChecker.cpp
  lib/StaticAnalyzer/Checkers/MPI-Checker/MPIBugReporter.cpp
  lib/StaticAnalyzer/Checkers/MPI-Checker/MPIBugReporter.h
  lib/StaticAnalyzer/Checkers/MPI-Checker/MPIChecker.cpp
  lib/StaticAnalyzer/Checkers/MPI-Checker/MPIChecker.h
  lib/StaticAnalyzer/Checkers/MallocChecker.cpp
  lib/StaticAnalyzer/Checkers/ObjCSuperDeallocChecker.cpp
  lib/StaticAnalyzer/Checkers/SimpleStreamChecker.cpp
  lib/StaticAnalyzer/Checkers/ValistChecker.cpp
  test/Analysis/malloc.c

Index: test/Analysis/malloc.c
===
--- test/Analysis/malloc.c
+++ test/Analysis/malloc.c
@@ -1720,13 +1720,6 @@
   }
 }
 
-char *dupstrWarn(const char *s) {
-  const int len = strlen(s);
-  char *p = (char*) smallocWarn(len + 1);
-  strcpy(p, s); // expected-warning{{String copy function overflows destination buffer}}
-  return p;
-}
-
 int *radar15580979() {
   int *data = (int *)malloc(32);
   int *p = data ?: (int*)malloc(32); // no warning
Index: lib/StaticAnalyzer/Checkers/ValistChecker.cpp
===
--- lib/StaticAnalyzer/Checkers/ValistChecker.cpp
+++ lib/StaticAnalyzer/Checkers/ValistChecker.cpp
@@ -64,7 +64,7 @@
  CheckerContext ) const;
   void reportLeakedVALists(const RegionVector , StringRef Msg1,
StringRef Msg2, CheckerContext , ExplodedNode *N,
-   bool ForceReport = false) const;
+   bool ReportUninit = false) const;
 
   void checkVAListStartCall(const CallEvent , CheckerContext ,
 bool IsCopy) const;
@@ -267,15 +267,15 @@
 void ValistChecker::reportLeakedVALists(const RegionVector ,
 StringRef Msg1, StringRef Msg2,
 CheckerContext , ExplodedNode *N,
-bool ForceReport) const {
+bool ReportUninit) const {
   if (!(ChecksEnabled[CK_Unterminated] ||
-(ChecksEnabled[CK_Uninitialized] && ForceReport)))
+(ChecksEnabled[CK_Uninitialized] && ReportUninit)))
 return;
   for (auto Reg : LeakedVALists) {
 if (!BT_leakedvalist) {
-  BT_leakedvalist.reset(new BugType(CheckNames[CK_Unterminated],
-"Leaked va_list",
-categories::MemoryError));
+  BT_leakedvalist.reset(new BugType(
+  CheckNames[ReportUninit ? CK_Uninitialized : CK_Unterminated],
+  "Leaked va_list", categories::MemoryError));
   BT_leakedvalist->setSuppressOnSink(true);
 }
 
@@ -375,7 +375,7 @@
 
 std::shared_ptr ValistChecker::ValistBugVisitor::VisitNode(
 const ExplodedNode *N, const ExplodedNode *PrevN, BugReporterContext ,
-BugReport ) {
+BugReport &) {
   ProgramStateRef State = N->getState();
   ProgramStateRef StatePrev = PrevN->getState();
 
Index: lib/StaticAnalyzer/Checkers/SimpleStreamChecker.cpp
===
--- lib/StaticAnalyzer/Checkers/SimpleStreamChecker.cpp
+++ lib/StaticAnalyzer/Checkers/SimpleStreamChecker.cpp
@@ -54,8 +54,8 @@
check::PointerEscape> {
   CallDescription OpenFn, CloseFn;
 
-  std::unique_ptr DoubleCloseBugType;
-  std::unique_ptr LeakBugType;
+  mutable std::unique_ptr DoubleCloseBugType;
+  mutable std::unique_ptr LeakBugType;
 
   void reportDoubleClose(SymbolRef FileDescSym,
  const CallEvent ,
@@ -104,16 +104,7 @@
 } // end anonymous namespace
 
 SimpleStreamChecker::SimpleStreamChecker()
-: OpenFn("fopen"), CloseFn("fclose", 1) {
-  // Initialize the bug types.
-  DoubleCloseBugType.reset(
-  new BugType(this, "Double fclose", "Unix Stream API Error"));
-
-  LeakBugType.reset(
-  new BugType(this, "Resource Leak", "Unix Stream API Error"));
-  // Sinks are higher importance bugs as well as calls to assert() or exit(0).
-  LeakBugType->setSuppressOnSink(true);
-}
+: OpenFn("fopen"), CloseFn("fclose", 1) {}
 
 void SimpleStreamChecker::checkPostCall(const 

[PATCH] D37465: [Bash-autocomplete] Fix crash when invoking --autocomplete without value.

2017-09-05 Thread Yuka Takahashi via Phabricator via cfe-commits
yamaguchi accepted this revision.
yamaguchi added a comment.
This revision is now accepted and ready to land.

LGTM! Thanks for the fix!


Repository:
  rL LLVM

https://reviews.llvm.org/D37465



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


[PATCH] D37448: Fix cast assertion on MS inline assembly with vector spills (PR34021)

2017-09-05 Thread coby via Phabricator via cfe-commits
coby added a comment.

might be a bit unrelated - but do we've got a hint regarding why is this even 
an issue?
by all means - it doesn't seems right for an empty ms inline-asm statement to 
affect successful compilation, without even mentioning the involvement of the 
encapsulating function's return type.
Another semi-adopted MS legacy issue?


Repository:
  rL LLVM

https://reviews.llvm.org/D37448



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


r312524 - [AMDGPU] Implement infrastructure to set options in AMDGPUToolChain

2017-09-05 Thread Andrey Kasaurov via cfe-commits
Author: kasaurov
Date: Tue Sep  5 03:24:38 2017
New Revision: 312524

URL: http://llvm.org/viewvc/llvm-project?rev=312524=rev
Log:
[AMDGPU] Implement infrastructure to set options in AMDGPUToolChain

In current OpenCL implementation some options are set in OpenCL RT/Driver, 
which causes discrepancy between online and offline paths.
Implement infrastructure to move options from OpenCL RT/Driver to 
AMDGPUToolChain using overloaded TranslateArgs() method.
Create map for default options values, as Options.td doesn't support default 
values (in contrast with OPTIONS.def).
Add two driver options: -On and -mNN (like -O3, -m64).
Some minor formatting changes to follow the clang-format style.

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

Added:
cfe/trunk/test/Driver/amdgpu-toolchain-opencl.cl
Modified:
cfe/trunk/lib/Driver/ToolChains/AMDGPU.cpp
cfe/trunk/lib/Driver/ToolChains/AMDGPU.h

Modified: cfe/trunk/lib/Driver/ToolChains/AMDGPU.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/AMDGPU.cpp?rev=312524=312523=312524=diff
==
--- cfe/trunk/lib/Driver/ToolChains/AMDGPU.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/AMDGPU.cpp Tue Sep  5 03:24:38 2017
@@ -8,8 +8,8 @@
 
//===--===//
 
 #include "AMDGPU.h"
-#include "InputInfo.h"
 #include "CommonArgs.h"
+#include "InputInfo.h"
 #include "clang/Driver/Compilation.h"
 #include "llvm/Option/ArgList.h"
 
@@ -38,8 +38,45 @@ void amdgpu::Linker::ConstructJob(Compil
 /// AMDGPU Toolchain
 AMDGPUToolChain::AMDGPUToolChain(const Driver , const llvm::Triple ,
  const ArgList )
-  : Generic_ELF(D, Triple, Args) { }
+: Generic_ELF(D, Triple, Args),
+  OptionsDefault({{options::OPT_O, "3"},
+  {options::OPT_cl_std_EQ, "CL1.2"}}) {}
 
 Tool *AMDGPUToolChain::buildLinker() const {
   return new tools::amdgpu::Linker(*this);
 }
+
+DerivedArgList *
+AMDGPUToolChain::TranslateArgs(const DerivedArgList , StringRef BoundArch,
+   Action::OffloadKind DeviceOffloadKind) const {
+
+  DerivedArgList *DAL =
+  Generic_ELF::TranslateArgs(Args, BoundArch, DeviceOffloadKind);
+
+  // Do nothing if not OpenCL (-x cl)
+  if (!Args.getLastArgValue(options::OPT_x).equals("cl"))
+return DAL;
+
+  if (!DAL)
+DAL = new DerivedArgList(Args.getBaseArgs());
+  for (auto *A : Args)
+DAL->append(A);
+
+  const OptTable  = getDriver().getOpts();
+
+  // Phase 1 (.cl -> .bc)
+  if (Args.hasArg(options::OPT_c) && Args.hasArg(options::OPT_emit_llvm)) {
+DAL->AddFlagArg(nullptr, Opts.getOption(getTriple().isArch64Bit()
+? options::OPT_m64
+: options::OPT_m32));
+
+// Have to check OPT_O4, OPT_O0 & OPT_Ofast separately
+// as they defined that way in Options.td
+if (!Args.hasArg(options::OPT_O, options::OPT_O0, options::OPT_O4,
+ options::OPT_Ofast))
+  DAL->AddJoinedArg(nullptr, Opts.getOption(options::OPT_O),
+getOptionDefault(options::OPT_O));
+  }
+
+  return DAL;
+}

Modified: cfe/trunk/lib/Driver/ToolChains/AMDGPU.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/AMDGPU.h?rev=312524=312523=312524=diff
==
--- cfe/trunk/lib/Driver/ToolChains/AMDGPU.h (original)
+++ cfe/trunk/lib/Driver/ToolChains/AMDGPU.h Tue Sep  5 03:24:38 2017
@@ -11,8 +11,10 @@
 #define LLVM_CLANG_LIB_DRIVER_TOOLCHAINS_AMDGPU_H
 
 #include "Gnu.h"
+#include "clang/Driver/Options.h"
 #include "clang/Driver/Tool.h"
 #include "clang/Driver/ToolChain.h"
+#include 
 
 namespace clang {
 namespace driver {
@@ -37,14 +39,26 @@ public:
 namespace toolchains {
 
 class LLVM_LIBRARY_VISIBILITY AMDGPUToolChain : public Generic_ELF {
+
+private:
+  const std::map OptionsDefault;
+
 protected:
   Tool *buildLinker() const override;
+  const StringRef getOptionDefault(options::ID OptID) const {
+auto opt = OptionsDefault.find(OptID);
+assert(opt != OptionsDefault.end() && "No Default for Option");
+return opt->second;
+  }
 
 public:
   AMDGPUToolChain(const Driver , const llvm::Triple ,
-const llvm::opt::ArgList );
+  const llvm::opt::ArgList );
   unsigned GetDefaultDwarfVersion() const override { return 2; }
   bool IsIntegratedAssemblerDefault() const override { return true; }
+  llvm::opt::DerivedArgList *
+  TranslateArgs(const llvm::opt::DerivedArgList , StringRef BoundArch,
+Action::OffloadKind DeviceOffloadKind) const override;
 };
 
 } // end namespace toolchains

Added: cfe/trunk/test/Driver/amdgpu-toolchain-opencl.cl
URL: 

[PATCH] D37466: D37461: fixups for existing InlineAsm tests + adding new ones

2017-09-05 Thread coby via Phabricator via cfe-commits
coby created this revision.
Herald added a subscriber: eraman.

Repository:
  rL LLVM

https://reviews.llvm.org/D37466

Files:
  test/CodeGen/ms-inline-asm-64.c
  test/CodeGen/ms-inline-asm-offset-err.cpp
  test/CodeGen/ms-inline-asm-offset.c
  test/CodeGen/ms-inline-asm.c
  test/CodeGen/ms-inline-asm.cpp

Index: test/CodeGen/ms-inline-asm.c
===
--- test/CodeGen/ms-inline-asm.c
+++ test/CodeGen/ms-inline-asm.c
@@ -180,25 +180,14 @@
 // CHECK: call void asm sideeffect inteldialect ".if 1\0A\09mov eax, $0\0A\09.else\0A\09mov ebx, j\0A\09.endif", "*m,~{eax},~{dirflag},~{fpsr},~{flags}"(i32* %{{.*}})
 }
 
-int gvar = 10;
 void t15() {
 // CHECK: t15
   int lvar = 10;
   __asm mov eax, lvar; eax = 10
 // CHECK: mov eax, $0
-  __asm mov eax, offset lvar ; eax = address of lvar
-// CHECK: mov eax, $1
-  __asm mov eax, offset gvar ; eax = address of gvar
-// CHECK: mov eax, $2
-// CHECK: "*m,r,r,~{eax},~{dirflag},~{fpsr},~{flags}"(i32* %{{.*}}, i32* %{{.*}}, i32* @{{.*}})
+// CHECK-SAME: "*m,~{eax},~{dirflag},~{fpsr},~{flags}"
 }
 
-void t16() {
-  int var = 10;
-  __asm mov [eax], offset var
-// CHECK: t16
-// CHECK: call void asm sideeffect inteldialect "mov [eax], $0", "r,~{dirflag},~{fpsr},~{flags}"(i32* %{{.*}})
-}
 
 void t17() {
 // CHECK: t17
Index: test/CodeGen/ms-inline-asm-64.c
===
--- test/CodeGen/ms-inline-asm-64.c
+++ test/CodeGen/ms-inline-asm-64.c
@@ -1,46 +1,28 @@
 // REQUIRES: x86-registered-target
 // RUN: %clang_cc1 %s -triple x86_64-apple-darwin10 -fasm-blocks -emit-llvm -o - | FileCheck %s
 
-void t1() {
-  int var = 10;
-  __asm mov rax, offset var ; rax = address of myvar
-// CHECK: t1
-// CHECK: call void asm sideeffect inteldialect
-// CHECK-SAME: mov rax, $0
-// CHECK-SAME: "r,~{rax},~{dirflag},~{fpsr},~{flags}"(i32* %{{.*}})
-}
-
-void t2() {
-  int var = 10;
-  __asm mov [eax], offset var
-// CHECK: t2
-// CHECK: call void asm sideeffect inteldialect
-// CHECK-SAME: mov [eax], $0
-// CHECK-SAME: "r,~{dirflag},~{fpsr},~{flags}"(i32* %{{.*}})
-}
-
-struct t3_type { int a, b; };
+struct t1_type { int a, b; };
 
-int t3() {
-  struct t3_type foo;
+int t1() {
+  struct t1_type foo;
   foo.a = 1;
   foo.b = 2;
   __asm {
  lea ebx, foo
  mov eax, [ebx].0
  mov [ebx].4, ecx
   }
   return foo.b;
-// CHECK: t3
+// CHECK: t1
 // CHECK: call void asm sideeffect inteldialect
 // CHECK-SAME: lea ebx, $0
 // CHECK-SAME: mov eax, [ebx]
 // CHECK-SAME: mov [ebx + $$4], ecx
-// CHECK-SAME: "*m,~{eax},~{ebx},~{dirflag},~{fpsr},~{flags}"(%struct.t3_type* %{{.*}})
+// CHECK-SAME: "*m,~{eax},~{ebx},~{dirflag},~{fpsr},~{flags}"(%struct.t1_type* %{{.*}})
 }
 
-int t4() {
-  struct t3_type foo;
+int t2() {
+  struct t1_type foo;
   foo.a = 1;
   foo.b = 2;
   __asm {
@@ -51,10 +33,10 @@
  mov [ebx].foo.b, ecx
   }
   return foo.b;
-// CHECK: t4
+// CHECK: t2
 // CHECK: call void asm sideeffect inteldialect
 // CHECK-SAME: lea ebx, $0
 // CHECK-SAME: mov eax, [ebx]
 // CHECK-SAME: mov [ebx + $$4], ecx
-// CHECK-SAME: "*m,~{eax},~{ebx},~{dirflag},~{fpsr},~{flags}"(%struct.t3_type* %{{.*}})
+// CHECK-SAME: "*m,~{eax},~{ebx},~{dirflag},~{fpsr},~{flags}"(%struct.t1_type* %{{.*}})
 }
Index: test/CodeGen/ms-inline-asm.cpp
===
--- test/CodeGen/ms-inline-asm.cpp
+++ test/CodeGen/ms-inline-asm.cpp
@@ -31,18 +31,6 @@
   __asm mov eax, dword ptr [Foo :: ptr]
 }
 
-int gvar = 10;
-void t2() {
-  int lvar = 10;
-  __asm mov eax, offset Foo::ptr
-  __asm mov eax, offset Foo::Bar::ptr
-// CHECK-LABEL: define void @_Z2t2v()
-// CHECK: call void asm sideeffect inteldialect
-// CHECK-SAME: mov eax, $0
-// CHECK-SAME: mov eax, $1
-// CHECK-SAME: "r,r,~{eax},~{dirflag},~{fpsr},~{flags}"(i32** @_ZN3Foo3ptrE, i32** @_ZN3Foo3Bar3ptrE)
-}
-
 // CHECK-LABEL: define void @_Z2t3v()
 void t3() {
   __asm mov eax, LENGTH Foo::ptr
Index: test/CodeGen/ms-inline-asm-offset.c
===
--- test/CodeGen/ms-inline-asm-offset.c
+++ test/CodeGen/ms-inline-asm-offset.c
@@ -0,0 +1,29 @@
+// REQUIRES: x86-registered-target
+// RUN: %clang_cc1 %s -triple x86_64-apple-darwin10 -fasm-blocks -emit-llvm -o - | FileCheck %s
+
+int gVar;
+void t1() {
+  __asm mov rax, 0xFF + offset gVar - 0xFE * 1
+  // CHECK: t1
+  // CHECK: mov rax, offset gVar + $$1
+}
+
+void t2() {
+  __asm mov edx, offset t2
+  // CHECK: t2
+  // CHECK: mov edx, offset t2
+}
+
+void t3() {
+  __asm _t3: mov eax, offset _t3
+  // CHECK: t3
+  // CHECK: {{.*}}__MSASMLABEL_.${:uid}___t3:
+  // CHECK: mov eax, offset {{.*}}__MSASMLABEL_.${:uid}___t3
+}
+
+void t4() {
+  __asm mov rbx, qword ptr 0x128[rax + offset t4 + rcx * 2]
+  // CHECK: t4
+  // CHECK: mov rbx, qword ptr [rax + rcx * $$2 + offset t4 + $$296]
+}
+
Index: test/CodeGen/ms-inline-asm-offset-err.cpp

[PATCH] D20689: [clang-tidy] Suspicious Call Argument checker

2017-09-05 Thread Barancsuk Lilla via Phabricator via cfe-commits
barancsuk updated this revision to Diff 113830.
barancsuk added a comment.

Check if argument and parameter numbers differ, add test cases for functions 
with default parameters


https://reviews.llvm.org/D20689

Files:
  clang-tidy/readability/CMakeLists.txt
  clang-tidy/readability/ReadabilityTidyModule.cpp
  clang-tidy/readability/SuspiciousCallArgumentCheck.cpp
  clang-tidy/readability/SuspiciousCallArgumentCheck.h
  docs/ReleaseNotes.rst
  docs/clang-tidy/checks/list.rst
  docs/clang-tidy/checks/misc-redundant-expression.rst
  docs/clang-tidy/checks/readability-suspicious-call-argument.rst
  test/clang-tidy/misc-redundant-expression.cpp
  test/clang-tidy/readability-suspicious-call-argument.cpp

Index: test/clang-tidy/readability-suspicious-call-argument.cpp
===
--- /dev/null
+++ test/clang-tidy/readability-suspicious-call-argument.cpp
@@ -0,0 +1,391 @@
+// RUN: %check_clang_tidy %s readability-suspicious-call-argument %t -- -- -std=c++11
+
+void foo_1(int aa, int bb) {}
+
+void foo_2(int source, int aa) {}
+
+void foo_3(int valToRet, int aa) {}
+
+void foo_4(int pointer, int aa) {}
+
+void foo_5(int aa, int bb, int cc, ...) {}
+
+void foo_6(const int dd, bool ) {}
+
+void foo_7(int aa, int bb, int cc, int ff = 7) {}
+
+// Test functions for convertible argument--parameter types.
+void fun(const int );
+void fun2() {
+  int m = 3;
+  fun(m);
+}
+
+// Test cases for parameters of const reference and value.
+void value_const_reference(int ll, const int );
+
+void const_ref_value_swapped() {
+  const int  = 42;
+  const int  = 42;
+  value_const_reference(kk, ll);
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: kk (ll) is swapped with ll (kk). [readability-suspicious-call-argument]
+}
+
+// Const, non const references.
+void const_nonconst_parameters(const int , int );
+
+void const_nonconst_swap1() {
+  const int& nn = 42;
+  int mm;
+  // Do not check, because non-const reference parameter cannot bind to const reference argument.
+  const_nonconst_parameters(nn, mm);
+}
+
+void const_nonconst_swap3() {
+  const int nn = 42;
+  int m = 42;
+  int  = m;
+  // Do not check, const int does not bind to non const reference.
+  const_nonconst_parameters(nn, mm);
+}
+
+void const_nonconst_swap2() {
+  int nn;
+  int mm;
+  // Check for swapped arguments. (Both arguments are non-const.)
+  const_nonconst_parameters(
+  nn,
+  mm);
+  // CHECK-MESSAGES: :[[@LINE-3]]:3: warning: nn (mm) is swapped with mm (nn). [readability-suspicious-call-argument]
+}
+
+void const_nonconst_pointers(const int* mm, int* nn);
+void const_nonconst_pointers2(const int* mm, const int* nn);
+
+void const_nonconst_pointers_swapped(){
+int* mm;
+const int* nn;
+const_nonconst_pointers(nn, mm);
+}
+
+void const_nonconst_pointers_swapped2() {
+  const int *mm;
+  int *nn;
+  const_nonconst_pointers2(nn, mm);
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: nn (mm) is swapped with mm (nn). [readability-suspicious-call-argument]
+}
+
+// Test cases for pointers and arrays.
+void pointer_array_parameters(
+int *pp, int qq[4]);
+
+void pointer_array_swap() {
+  int qq[5];
+  int *pp;
+  // Check for swapped arguments. An array implicitly converts to a pointer.
+  pointer_array_parameters(qq, pp);
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: qq (pp) is swapped with pp (qq). [readability-suspicious-call-argument]
+}
+
+// Test cases for multilevel pointers.
+void multilevel_pointer_parameters(int *const **pp,
+   const int *const *volatile const *qq);
+void multilevel_pointer_parameters2(
+char *nn, char *volatile *const *const *const *const );
+
+typedef float T;
+typedef T * S;
+typedef S *const volatile R;
+typedef R * Q;
+typedef Q * P;
+typedef P * O;
+void multilevel_pointer_parameters3(float **const volatile ***rr, O );
+
+void multilevel_pointer_swap() {
+  int *const ** qq;
+  int *const ** pp;
+  multilevel_pointer_parameters(qq, pp);
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: qq (pp) is swapped with pp (qq). [readability-suspicious-call-argument]
+
+  char *mm;
+  char *nn;
+  multilevel_pointer_parameters2(mm, nn);
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: mm (nn) is swapped with nn (mm). [readability-suspicious-call-argument]
+
+  float **const volatile *** rr;
+  float **const volatile *** ss;
+  multilevel_pointer_parameters3(ss, rr);
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: ss (rr) is swapped with rr (ss). [readability-suspicious-call-argument]
+}
+
+void multilevel_pointer_parameters4(char pp,
+ 

[PATCH] D37465: [Bash-autocomplete] Fix crash when invoking --autocomplete without value.

2017-09-05 Thread Raphael Isemann via Phabricator via cfe-commits
teemperor created this revision.

Currently clang segfaults when invoked with `clang --autocomplete=`.
This patch adds the necessary boundary checks and some tests for corner cases 
like this.


Repository:
  rL LLVM

https://reviews.llvm.org/D37465

Files:
  lib/Driver/Driver.cpp
  test/Driver/autocomplete.c


Index: test/Driver/autocomplete.c
===
--- test/Driver/autocomplete.c
+++ test/Driver/autocomplete.c
@@ -2,6 +2,19 @@
 // autocompletion. You may have to update tests in this file when you
 // 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=-fsyn | FileCheck %s -check-prefix=FSYN
 // FSYN: -fsyntax-only
 // RUN: %clang --autocomplete=-std= | FileCheck %s -check-prefix=STD
Index: lib/Driver/Driver.cpp
===
--- lib/Driver/Driver.cpp
+++ lib/Driver/Driver.cpp
@@ -1165,12 +1165,10 @@
   unsigned short DisableFlags =
   options::NoDriverOption | options::Unsupported | options::Ignored;
   // We want to show cc1-only options only when clang is invoked as "clang
-  // -cc1".
-  // When clang is invoked as "clang -cc1", we add "#" to the beginning of an
-  // --autocomplete
-  // option so that the clang driver can distinguish whether it is requested to
-  // show cc1-only options or not.
-  if (PassedFlags[0] == '#') {
+  // -cc1". When clang is invoked as "clang -cc1", we add "#" to the beginning
+  // of an --autocomplete  option so that the clang driver can distinguish
+  // whether it is requested to show cc1-only options or not.
+  if (PassedFlags.size() > 0 && PassedFlags[0] == '#') {
 DisableFlags &= ~options::NoDriverOption;
 PassedFlags = PassedFlags.substr(1);
   }


Index: test/Driver/autocomplete.c
===
--- test/Driver/autocomplete.c
+++ test/Driver/autocomplete.c
@@ -2,6 +2,19 @@
 // autocompletion. You may have to update tests in this file when you
 // 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=-fsyn | FileCheck %s -check-prefix=FSYN
 // FSYN: -fsyntax-only
 // RUN: %clang --autocomplete=-std= | FileCheck %s -check-prefix=STD
Index: lib/Driver/Driver.cpp
===
--- lib/Driver/Driver.cpp
+++ lib/Driver/Driver.cpp
@@ -1165,12 +1165,10 @@
   unsigned short DisableFlags =
   options::NoDriverOption | options::Unsupported | options::Ignored;
   // We want to show cc1-only options only when clang is invoked as "clang
-  // -cc1".
-  // When clang is invoked as "clang -cc1", we add "#" to the beginning of an
-  // --autocomplete
-  // option so that the clang driver can distinguish whether it is requested to
-  // show cc1-only options or not.
-  if (PassedFlags[0] == '#') {
+  // -cc1". When clang is invoked as "clang -cc1", we add "#" to the beginning
+  // of an --autocomplete  option so that the clang driver can distinguish
+  // whether it is requested to show cc1-only options or not.
+  if (PassedFlags.size() > 0 && PassedFlags[0] == '#') {
 DisableFlags &= ~options::NoDriverOption;
 PassedFlags = PassedFlags.substr(1);
   }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r312525 - Removed dead code (PR34467). NFCI.

2017-09-05 Thread Simon Pilgrim via cfe-commits
Author: rksimon
Date: Tue Sep  5 03:37:13 2017
New Revision: 312525

URL: http://llvm.org/viewvc/llvm-project?rev=312525=rev
Log:
Removed dead code (PR34467). NFCI.

The for loop already checks that Idx < NumOfArgs.

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

Modified: cfe/trunk/lib/StaticAnalyzer/Core/CallEvent.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Core/CallEvent.cpp?rev=312525=312524=312525=diff
==
--- cfe/trunk/lib/StaticAnalyzer/Core/CallEvent.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Core/CallEvent.cpp Tue Sep  5 03:37:13 2017
@@ -97,9 +97,6 @@ bool CallEvent::hasNonNullArgumentsWithT
   for (CallEvent::param_type_iterator I = param_type_begin(),
   E = param_type_end();
I != E && Idx < NumOfArgs; ++I, ++Idx) {
-if (NumOfArgs <= Idx)
-  break;
-
 // If the parameter is 0, it's harmless.
 if (getArgSVal(Idx).isZeroConstant())
   continue;


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


[PATCH] D36574: [refactor] add clang-refactor tool with initial testing support and local-rename action

2017-09-05 Thread Alex Lorenz via Phabricator via cfe-commits
arphaman updated this revision to Diff 113826.
arphaman marked 6 inline comments as done.
arphaman added a comment.

- Always pass in `RefactoringRuleContext` to the refactoring rule's function.
- Remove now redundant overloads.
- Make LocalRename's actions members private.
- Add CommandLienParser FIXME comment.
- Verify that refactoring actions have unique command names.
- Add a comment that explains how a subcommand is selected.


Repository:
  rL LLVM

https://reviews.llvm.org/D36574

Files:
  include/clang/Tooling/Refactoring/AtomicChange.h
  include/clang/Tooling/Refactoring/RefactoringAction.h
  include/clang/Tooling/Refactoring/RefactoringActionRegistry.def
  include/clang/Tooling/Refactoring/RefactoringActionRule.h
  include/clang/Tooling/Refactoring/RefactoringActionRuleRequirementsInternal.h
  include/clang/Tooling/Refactoring/RefactoringActionRules.h
  include/clang/Tooling/Refactoring/RefactoringActionRulesInternal.h
  include/clang/Tooling/Refactoring/RefactoringRuleContext.h
  include/clang/Tooling/Refactoring/Rename/USRFindingAction.h
  include/clang/Tooling/Refactoring/SourceSelectionConstraints.h
  include/clang/module.modulemap
  lib/Tooling/Refactoring/AtomicChange.cpp
  lib/Tooling/Refactoring/CMakeLists.txt
  lib/Tooling/Refactoring/RefactoringActions.cpp
  lib/Tooling/Refactoring/Rename/RenamingAction.cpp
  lib/Tooling/Refactoring/Rename/USRFindingAction.cpp
  test/CMakeLists.txt
  test/Refactor/LocalRename/Field.cpp
  test/Refactor/tool-common-options.c
  test/Refactor/tool-test-support.c
  test/clang-rename/Field.cpp
  tools/CMakeLists.txt
  tools/clang-refactor/CMakeLists.txt
  tools/clang-refactor/ClangRefactor.cpp
  tools/clang-refactor/TestSupport.cpp
  tools/clang-refactor/TestSupport.h
  unittests/Tooling/RefactoringActionRulesTest.cpp

Index: unittests/Tooling/RefactoringActionRulesTest.cpp
===
--- unittests/Tooling/RefactoringActionRulesTest.cpp
+++ unittests/Tooling/RefactoringActionRulesTest.cpp
@@ -54,7 +54,8 @@
 
 TEST_F(RefactoringActionRulesTest, MyFirstRefactoringRule) {
   auto ReplaceAWithB =
-  [](std::pair Selection)
+  [](const RefactoringRuleContext &,
+ std::pair Selection)
   -> Expected {
 const SourceManager  = Selection.first.getSources();
 SourceLocation Loc = Selection.first.getRange().getBegin().getLocWithOffset(
@@ -68,7 +69,8 @@
   class SelectionRequirement : public selection::Requirement {
   public:
 std::pair
-evaluateSelection(selection::SourceSelectionRange Selection) const {
+evaluateSelection(const RefactoringRuleContext &,
+  selection::SourceSelectionRange Selection) const {
   return std::make_pair(Selection, 20);
 }
   };
@@ -124,8 +126,10 @@
 }
 
 TEST_F(RefactoringActionRulesTest, ReturnError) {
-  Expected (*Func)(selection::SourceSelectionRange) =
-  [](selection::SourceSelectionRange) -> Expected {
+  Expected (*Func)(const RefactoringRuleContext &,
+  selection::SourceSelectionRange) =
+  [](const RefactoringRuleContext &,
+ selection::SourceSelectionRange) -> Expected {
 return llvm::make_error(
 "Error", llvm::make_error_code(llvm::errc::invalid_argument));
   };
@@ -152,13 +156,14 @@
   class SelectionRequirement : public selection::Requirement {
   public:
 Expected
-evaluateSelection(selection::SourceSelectionRange Selection) const {
+evaluateSelection(const RefactoringRuleContext &,
+  selection::SourceSelectionRange Selection) const {
   return llvm::make_error(
   "bad selection", llvm::make_error_code(llvm::errc::invalid_argument));
 }
   };
   auto Rule = createRefactoringRule(
-  [](int) -> Expected {
+  [](const RefactoringRuleContext &, int) -> Expected {
 llvm::report_fatal_error("Should not run!");
   },
   requiredSelection(SelectionRequirement()));
@@ -195,7 +200,8 @@
 
 TEST_F(RefactoringActionRulesTest, ReturnSymbolOccurrences) {
   auto Rule = createRefactoringRule(
-  [](selection::SourceSelectionRange Selection)
+  [](const RefactoringRuleContext &,
+ selection::SourceSelectionRange Selection)
   -> Expected {
 SymbolOccurrences Occurrences;
 Occurrences.push_back(SymbolOccurrence(
Index: tools/clang-refactor/TestSupport.h
===
--- /dev/null
+++ tools/clang-refactor/TestSupport.h
@@ -0,0 +1,104 @@
+//===--- TestSupport.h - Clang-based refactoring tool ---*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//

[PATCH] D36574: [refactor] add clang-refactor tool with initial testing support and local-rename action

2017-09-05 Thread Alex Lorenz via Phabricator via cfe-commits
arphaman added inline comments.



Comment at: 
include/clang/Tooling/Refactoring/RefactoringActionRulesInternal.h:99
+  template 
+  void invokeImplDispatch(
+  RefactoringResultConsumer , RefactoringRuleContext &,

ioeric wrote:
> Do we still need this overload?
Removed.



Comment at: tools/clang-refactor/ClangRefactor.cpp:60
+  : SubCommand(Name, Description), Action() {
+Sources = llvm::make_unique(
+cl::Positional, cl::ZeroOrMore, cl::desc(" [... ]"),

ioeric wrote:
> arphaman wrote:
> > arphaman wrote:
> > > ioeric wrote:
> > > > I think you would get a conflict of positional args when you have 
> > > > multiple sub-command instances.
> > > > 
> > > > Any reason not to use `clang::tooling::CommonOptionsParser` which takes 
> > > > care of sources and compilation options for you? 
> > > Not from my experience, I've tried multiple actions it seems like the 
> > > right arguments are parsed for the right subcommand. It looks like the cl 
> > > option parser looks is smart enough to handle identical options across 
> > > multiple subcommands.
> > I agree that using `CommonOptionsParser` would be preferable, but right now 
> > it doesn't work well with subcommands. I will create a followup patch that 
> > improves subcommand support in `CommonOptionsParser` and uses them in 
> > clang-refactor when this patch is accepted.
> Thanks! Could you add a `FIXME` for the `CommonOptionsParser` change?
> 
> 
Done.



Comment at: tools/clang-refactor/ClangRefactor.cpp:312
+  [](const std::unique_ptr ) {
+return !!(*SubCommand);
+  });

ioeric wrote:
> arphaman wrote:
> > ioeric wrote:
> > > Do we need a `FIXME` here?  It seems that this simply finds the first 
> > > command that is available? What if there are more than one commands that 
> > > satisfy the requirements?
> > I don't quite follow, when would multiple subcommands be satisfied? The 
> > subcommand corresponds to the action that the user wants to do, there 
> > should be no ambiguity.
> (I added this comment a while ago, and it seemed to have shifted. I was 
> intended to comment on line 297 `  auto It = llvm::find_if(`. Sorry about 
> that.)
> 
> I guess I don't quite understand how a specific subcommand is picked based on 
> the commandline options users provide. The `llvm::find_if` above seems to 
> simply find the first action/subcommand that is registered? Could you add a 
> comment about how submamands are matched?
Ah, I see.

I added a comment in the updated patch that tries to explain the process. 
Basically we know that one action maps to just one subcommand because the 
actions must have unique command names. Since we've already created the 
subcommands, LLVM's command-line parser enables one particular subcommand that 
was specified in the command-line arguments. This is what this search does, we 
just look for the enabled subcommand that was turned on by LLVM's command-line 
parser, without taking any other command-line arguments into account.


Repository:
  rL LLVM

https://reviews.llvm.org/D36574



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


[PATCH] D36836: [clang-tidy] Implement readability-function-cognitive-complexity check

2017-09-05 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri added a comment.

I understand that everyone is likely busy with 5.0, but still,
give me at least some feedback, please :)   ping


Repository:
  rL LLVM

https://reviews.llvm.org/D36836



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


[PATCH] D37386: [AMDGPU] Implement infrastructure to set options in AMDGPUToolChain

2017-09-05 Thread Andrey Kasaurov via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL312524: [AMDGPU] Implement infrastructure to set options in 
AMDGPUToolChain (authored by kasaurov).

Changed prior to commit:
  https://reviews.llvm.org/D37386?vs=113780=113825#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D37386

Files:
  cfe/trunk/lib/Driver/ToolChains/AMDGPU.cpp
  cfe/trunk/lib/Driver/ToolChains/AMDGPU.h
  cfe/trunk/test/Driver/amdgpu-toolchain-opencl.cl

Index: cfe/trunk/lib/Driver/ToolChains/AMDGPU.h
===
--- cfe/trunk/lib/Driver/ToolChains/AMDGPU.h
+++ cfe/trunk/lib/Driver/ToolChains/AMDGPU.h
@@ -11,8 +11,10 @@
 #define LLVM_CLANG_LIB_DRIVER_TOOLCHAINS_AMDGPU_H
 
 #include "Gnu.h"
+#include "clang/Driver/Options.h"
 #include "clang/Driver/Tool.h"
 #include "clang/Driver/ToolChain.h"
+#include 
 
 namespace clang {
 namespace driver {
@@ -37,14 +39,26 @@
 namespace toolchains {
 
 class LLVM_LIBRARY_VISIBILITY AMDGPUToolChain : public Generic_ELF {
+
+private:
+  const std::map OptionsDefault;
+
 protected:
   Tool *buildLinker() const override;
+  const StringRef getOptionDefault(options::ID OptID) const {
+auto opt = OptionsDefault.find(OptID);
+assert(opt != OptionsDefault.end() && "No Default for Option");
+return opt->second;
+  }
 
 public:
   AMDGPUToolChain(const Driver , const llvm::Triple ,
-const llvm::opt::ArgList );
+  const llvm::opt::ArgList );
   unsigned GetDefaultDwarfVersion() const override { return 2; }
   bool IsIntegratedAssemblerDefault() const override { return true; }
+  llvm::opt::DerivedArgList *
+  TranslateArgs(const llvm::opt::DerivedArgList , StringRef BoundArch,
+Action::OffloadKind DeviceOffloadKind) const override;
 };
 
 } // end namespace toolchains
Index: cfe/trunk/lib/Driver/ToolChains/AMDGPU.cpp
===
--- cfe/trunk/lib/Driver/ToolChains/AMDGPU.cpp
+++ cfe/trunk/lib/Driver/ToolChains/AMDGPU.cpp
@@ -8,8 +8,8 @@
 //===--===//
 
 #include "AMDGPU.h"
-#include "InputInfo.h"
 #include "CommonArgs.h"
+#include "InputInfo.h"
 #include "clang/Driver/Compilation.h"
 #include "llvm/Option/ArgList.h"
 
@@ -38,8 +38,45 @@
 /// AMDGPU Toolchain
 AMDGPUToolChain::AMDGPUToolChain(const Driver , const llvm::Triple ,
  const ArgList )
-  : Generic_ELF(D, Triple, Args) { }
+: Generic_ELF(D, Triple, Args),
+  OptionsDefault({{options::OPT_O, "3"},
+  {options::OPT_cl_std_EQ, "CL1.2"}}) {}
 
 Tool *AMDGPUToolChain::buildLinker() const {
   return new tools::amdgpu::Linker(*this);
 }
+
+DerivedArgList *
+AMDGPUToolChain::TranslateArgs(const DerivedArgList , StringRef BoundArch,
+   Action::OffloadKind DeviceOffloadKind) const {
+
+  DerivedArgList *DAL =
+  Generic_ELF::TranslateArgs(Args, BoundArch, DeviceOffloadKind);
+
+  // Do nothing if not OpenCL (-x cl)
+  if (!Args.getLastArgValue(options::OPT_x).equals("cl"))
+return DAL;
+
+  if (!DAL)
+DAL = new DerivedArgList(Args.getBaseArgs());
+  for (auto *A : Args)
+DAL->append(A);
+
+  const OptTable  = getDriver().getOpts();
+
+  // Phase 1 (.cl -> .bc)
+  if (Args.hasArg(options::OPT_c) && Args.hasArg(options::OPT_emit_llvm)) {
+DAL->AddFlagArg(nullptr, Opts.getOption(getTriple().isArch64Bit()
+? options::OPT_m64
+: options::OPT_m32));
+
+// Have to check OPT_O4, OPT_O0 & OPT_Ofast separately
+// as they defined that way in Options.td
+if (!Args.hasArg(options::OPT_O, options::OPT_O0, options::OPT_O4,
+ options::OPT_Ofast))
+  DAL->AddJoinedArg(nullptr, Opts.getOption(options::OPT_O),
+getOptionDefault(options::OPT_O));
+  }
+
+  return DAL;
+}
Index: cfe/trunk/test/Driver/amdgpu-toolchain-opencl.cl
===
--- cfe/trunk/test/Driver/amdgpu-toolchain-opencl.cl
+++ cfe/trunk/test/Driver/amdgpu-toolchain-opencl.cl
@@ -0,0 +1,19 @@
+// RUN: %clang -### -target amdgcn-amd-amdhsa-opencl -x cl -c -emit-llvm -mcpu=fiji -O0 %s 2>&1 | FileCheck -check-prefix=CHECK_O0 %s
+// RUN: %clang -### -target amdgcn-amd-amdhsa-opencl -x cl -c -emit-llvm -mcpu=fiji -O1 %s 2>&1 | FileCheck -check-prefix=CHECK_O1 %s
+// RUN: %clang -### -target amdgcn-amd-amdhsa-opencl -x cl -c -emit-llvm -mcpu=fiji -O2 %s 2>&1 | FileCheck -check-prefix=CHECK_O2 %s
+// RUN: %clang -### -target amdgcn-amd-amdhsa-opencl -x cl -c -emit-llvm -mcpu=fiji -O3 %s 2>&1 | FileCheck -check-prefix=CHECK_O3 %s
+// RUN: %clang -### -target amdgcn-amd-amdhsa-opencl -x cl -c -emit-llvm -mcpu=fiji -O4 %s 2>&1 | FileCheck -check-prefix=CHECK_O4 %s
+// RUN: %clang -### -target 

r312523 - [X86][AVX512] _mm512_stream_load_si512 should take a void const* argument (PR33977)

2017-09-05 Thread Simon Pilgrim via cfe-commits
Author: rksimon
Date: Tue Sep  5 03:06:41 2017
New Revision: 312523

URL: http://llvm.org/viewvc/llvm-project?rev=312523=rev
Log:
[X86][AVX512] _mm512_stream_load_si512 should take a void const* argument 
(PR33977)

Based off the Intel Intrinsics guide, we should expect a void const* argument.

Prevents 'passing 'const void *' to parameter of type 'void *' discards 
qualifiers' warnings.

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

Modified:
cfe/trunk/lib/Headers/avx512fintrin.h
cfe/trunk/test/CodeGen/avx512f-builtins.c

Modified: cfe/trunk/lib/Headers/avx512fintrin.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/avx512fintrin.h?rev=312523=312522=312523=diff
==
--- cfe/trunk/lib/Headers/avx512fintrin.h (original)
+++ cfe/trunk/lib/Headers/avx512fintrin.h Tue Sep  5 03:06:41 2017
@@ -9040,7 +9040,7 @@ _mm512_stream_si512 (__m512i * __P, __m5
 }
 
 static __inline__ __m512i __DEFAULT_FN_ATTRS
-_mm512_stream_load_si512 (void *__P)
+_mm512_stream_load_si512 (void const *__P)
 {
   typedef __v8di __v8di_aligned __attribute__((aligned(64)));
   return (__m512i) __builtin_nontemporal_load((const __v8di_aligned *)__P);

Modified: cfe/trunk/test/CodeGen/avx512f-builtins.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/avx512f-builtins.c?rev=312523=312522=312523=diff
==
--- cfe/trunk/test/CodeGen/avx512f-builtins.c (original)
+++ cfe/trunk/test/CodeGen/avx512f-builtins.c Tue Sep  5 03:06:41 2017
@@ -6258,6 +6258,12 @@ __m512i test_mm512_stream_load_si512(voi
   return _mm512_stream_load_si512(__P); 
 }
 
+__m512i test_mm512_stream_load_si512_const(void const *__P) {
+  // CHECK-LABEL: @test_mm512_stream_load_si512_const
+  // CHECK: load <8 x i64>, <8 x i64>* %{{.*}}, align 64, !nontemporal
+  return _mm512_stream_load_si512(__P); 
+}
+
 void test_mm512_stream_pd(double *__P, __m512d __A) {
   // CHECK-LABEL: @test_mm512_stream_pd
   // CHECK: store <8 x double> %{{.*}}, <8 x double>* %{{.*}}, align 64, 
!nontemporal


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


[PATCH] D37449: [X86][AVX512] _mm512_stream_load_si512 should take a void const* argument (PR33977)

2017-09-05 Thread Simon Pilgrim via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL312523: [X86][AVX512] _mm512_stream_load_si512 should take a 
void const* argument… (authored by RKSimon).

Changed prior to commit:
  https://reviews.llvm.org/D37449?vs=113786=113819#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D37449

Files:
  cfe/trunk/lib/Headers/avx512fintrin.h
  cfe/trunk/test/CodeGen/avx512f-builtins.c


Index: cfe/trunk/test/CodeGen/avx512f-builtins.c
===
--- cfe/trunk/test/CodeGen/avx512f-builtins.c
+++ cfe/trunk/test/CodeGen/avx512f-builtins.c
@@ -6258,6 +6258,12 @@
   return _mm512_stream_load_si512(__P); 
 }
 
+__m512i test_mm512_stream_load_si512_const(void const *__P) {
+  // CHECK-LABEL: @test_mm512_stream_load_si512_const
+  // CHECK: load <8 x i64>, <8 x i64>* %{{.*}}, align 64, !nontemporal
+  return _mm512_stream_load_si512(__P); 
+}
+
 void test_mm512_stream_pd(double *__P, __m512d __A) {
   // CHECK-LABEL: @test_mm512_stream_pd
   // CHECK: store <8 x double> %{{.*}}, <8 x double>* %{{.*}}, align 64, 
!nontemporal
Index: cfe/trunk/lib/Headers/avx512fintrin.h
===
--- cfe/trunk/lib/Headers/avx512fintrin.h
+++ cfe/trunk/lib/Headers/avx512fintrin.h
@@ -9040,7 +9040,7 @@
 }
 
 static __inline__ __m512i __DEFAULT_FN_ATTRS
-_mm512_stream_load_si512 (void *__P)
+_mm512_stream_load_si512 (void const *__P)
 {
   typedef __v8di __v8di_aligned __attribute__((aligned(64)));
   return (__m512i) __builtin_nontemporal_load((const __v8di_aligned *)__P);


Index: cfe/trunk/test/CodeGen/avx512f-builtins.c
===
--- cfe/trunk/test/CodeGen/avx512f-builtins.c
+++ cfe/trunk/test/CodeGen/avx512f-builtins.c
@@ -6258,6 +6258,12 @@
   return _mm512_stream_load_si512(__P); 
 }
 
+__m512i test_mm512_stream_load_si512_const(void const *__P) {
+  // CHECK-LABEL: @test_mm512_stream_load_si512_const
+  // CHECK: load <8 x i64>, <8 x i64>* %{{.*}}, align 64, !nontemporal
+  return _mm512_stream_load_si512(__P); 
+}
+
 void test_mm512_stream_pd(double *__P, __m512d __A) {
   // CHECK-LABEL: @test_mm512_stream_pd
   // CHECK: store <8 x double> %{{.*}}, <8 x double>* %{{.*}}, align 64, !nontemporal
Index: cfe/trunk/lib/Headers/avx512fintrin.h
===
--- cfe/trunk/lib/Headers/avx512fintrin.h
+++ cfe/trunk/lib/Headers/avx512fintrin.h
@@ -9040,7 +9040,7 @@
 }
 
 static __inline__ __m512i __DEFAULT_FN_ATTRS
-_mm512_stream_load_si512 (void *__P)
+_mm512_stream_load_si512 (void const *__P)
 {
   typedef __v8di __v8di_aligned __attribute__((aligned(64)));
   return (__m512i) __builtin_nontemporal_load((const __v8di_aligned *)__P);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D36574: [refactor] add clang-refactor tool with initial testing support and local-rename action

2017-09-05 Thread Eric Liu via Phabricator via cfe-commits
ioeric added inline comments.



Comment at: include/clang/Tooling/Refactoring/RefactoringActionRules.h:45
 std::unique_ptr
 createRefactoringRule(Expected (*RefactoringFunction)(
   typename RequirementTypes::OutputType...),

Can we get rid of this overload and simply make `RefactoringRuleContext` 
mandatory for all refactoring functions? 



Comment at: 
include/clang/Tooling/Refactoring/RefactoringActionRulesInternal.h:99
+  template 
+  void invokeImplDispatch(
+  RefactoringResultConsumer , RefactoringRuleContext &,

Do we still need this overload?



Comment at: include/clang/Tooling/Refactoring/RefactoringRuleContext.h:44
 
+  ASTContext () const {
+assert(AST && "no AST!");

Should we also provide an interface to test if this has an `ASTContext`? Or 
maybe simply return null if there is `ASTContext`? WDYT?



Comment at: lib/Tooling/Refactoring/Rename/RenamingAction.cpp:50
+
+  static Expected
+  renameOccurrences(const RefactoringRuleContext ,

Should this be private?



Comment at: tools/clang-refactor/ClangRefactor.cpp:60
+  : SubCommand(Name, Description), Action() {
+Sources = llvm::make_unique(
+cl::Positional, cl::ZeroOrMore, cl::desc(" [... ]"),

arphaman wrote:
> arphaman wrote:
> > ioeric wrote:
> > > I think you would get a conflict of positional args when you have 
> > > multiple sub-command instances.
> > > 
> > > Any reason not to use `clang::tooling::CommonOptionsParser` which takes 
> > > care of sources and compilation options for you? 
> > Not from my experience, I've tried multiple actions it seems like the right 
> > arguments are parsed for the right subcommand. It looks like the cl option 
> > parser looks is smart enough to handle identical options across multiple 
> > subcommands.
> I agree that using `CommonOptionsParser` would be preferable, but right now 
> it doesn't work well with subcommands. I will create a followup patch that 
> improves subcommand support in `CommonOptionsParser` and uses them in 
> clang-refactor when this patch is accepted.
Thanks! Could you add a `FIXME` for the `CommonOptionsParser` change?





Comment at: tools/clang-refactor/ClangRefactor.cpp:312
+  [](const std::unique_ptr ) {
+return !!(*SubCommand);
+  });

arphaman wrote:
> ioeric wrote:
> > Do we need a `FIXME` here?  It seems that this simply finds the first 
> > command that is available? What if there are more than one commands that 
> > satisfy the requirements?
> I don't quite follow, when would multiple subcommands be satisfied? The 
> subcommand corresponds to the action that the user wants to do, there should 
> be no ambiguity.
(I added this comment a while ago, and it seemed to have shifted. I was 
intended to comment on line 297 `  auto It = llvm::find_if(`. Sorry about that.)

I guess I don't quite understand how a specific subcommand is picked based on 
the commandline options users provide. The `llvm::find_if` above seems to 
simply find the first action/subcommand that is registered? Could you add a 
comment about how submamands are matched?


Repository:
  rL LLVM

https://reviews.llvm.org/D36574



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


[PATCH] D37386: [AMDGPU] Implement infrastructure to set options in AMDGPUToolChain

2017-09-05 Thread Evgeny Mankov via Phabricator via cfe-commits
emankov accepted this revision.
emankov added a comment.

LGTM


https://reviews.llvm.org/D37386



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


[PATCH] D36574: [refactor] add clang-refactor tool with initial testing support and local-rename action

2017-09-05 Thread Alex Lorenz via Phabricator via cfe-commits
arphaman added inline comments.



Comment at: tools/clang-refactor/ClangRefactor.cpp:60
+  : SubCommand(Name, Description), Action() {
+Sources = llvm::make_unique(
+cl::Positional, cl::ZeroOrMore, cl::desc(" [... ]"),

arphaman wrote:
> ioeric wrote:
> > I think you would get a conflict of positional args when you have multiple 
> > sub-command instances.
> > 
> > Any reason not to use `clang::tooling::CommonOptionsParser` which takes 
> > care of sources and compilation options for you? 
> Not from my experience, I've tried multiple actions it seems like the right 
> arguments are parsed for the right subcommand. It looks like the cl option 
> parser looks is smart enough to handle identical options across multiple 
> subcommands.
I agree that using `CommonOptionsParser` would be preferable, but right now it 
doesn't work well with subcommands. I will create a followup patch that 
improves subcommand support in `CommonOptionsParser` and uses them in 
clang-refactor when this patch is accepted.


Repository:
  rL LLVM

https://reviews.llvm.org/D36574



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


[PATCH] D36574: [refactor] add clang-refactor tool with initial testing support and local-rename action

2017-09-05 Thread Alex Lorenz via Phabricator via cfe-commits
arphaman updated this revision to Diff 113804.
arphaman marked 8 inline comments as done.
arphaman added a comment.

- Test by checking the modified source directly. This allowed me to get rid of 
the refactoring result wrapper as well.
- Remove ASTRefactoringContext
- Address the other review comments


Repository:
  rL LLVM

https://reviews.llvm.org/D36574

Files:
  include/clang/Tooling/Refactoring/AtomicChange.h
  include/clang/Tooling/Refactoring/RefactoringAction.h
  include/clang/Tooling/Refactoring/RefactoringActionRegistry.def
  include/clang/Tooling/Refactoring/RefactoringActionRule.h
  include/clang/Tooling/Refactoring/RefactoringActionRuleRequirementsInternal.h
  include/clang/Tooling/Refactoring/RefactoringActionRules.h
  include/clang/Tooling/Refactoring/RefactoringActionRulesInternal.h
  include/clang/Tooling/Refactoring/RefactoringRuleContext.h
  include/clang/Tooling/Refactoring/Rename/USRFindingAction.h
  include/clang/Tooling/Refactoring/SourceSelectionConstraints.h
  include/clang/module.modulemap
  lib/Tooling/Refactoring/AtomicChange.cpp
  lib/Tooling/Refactoring/CMakeLists.txt
  lib/Tooling/Refactoring/RefactoringActions.cpp
  lib/Tooling/Refactoring/Rename/RenamingAction.cpp
  lib/Tooling/Refactoring/Rename/USRFindingAction.cpp
  test/CMakeLists.txt
  test/Refactor/LocalRename/Field.cpp
  test/Refactor/tool-common-options.c
  test/Refactor/tool-test-support.c
  test/clang-rename/Field.cpp
  tools/CMakeLists.txt
  tools/clang-refactor/CMakeLists.txt
  tools/clang-refactor/ClangRefactor.cpp
  tools/clang-refactor/TestSupport.cpp
  tools/clang-refactor/TestSupport.h
  unittests/Tooling/RefactoringActionRulesTest.cpp

Index: unittests/Tooling/RefactoringActionRulesTest.cpp
===
--- unittests/Tooling/RefactoringActionRulesTest.cpp
+++ unittests/Tooling/RefactoringActionRulesTest.cpp
@@ -68,7 +68,8 @@
   class SelectionRequirement : public selection::Requirement {
   public:
 std::pair
-evaluateSelection(selection::SourceSelectionRange Selection) const {
+evaluateSelection(const RefactoringRuleContext &,
+  selection::SourceSelectionRange Selection) const {
   return std::make_pair(Selection, 20);
 }
   };
@@ -152,7 +153,8 @@
   class SelectionRequirement : public selection::Requirement {
   public:
 Expected
-evaluateSelection(selection::SourceSelectionRange Selection) const {
+evaluateSelection(const RefactoringRuleContext &,
+  selection::SourceSelectionRange Selection) const {
   return llvm::make_error(
   "bad selection", llvm::make_error_code(llvm::errc::invalid_argument));
 }
Index: tools/clang-refactor/TestSupport.h
===
--- /dev/null
+++ tools/clang-refactor/TestSupport.h
@@ -0,0 +1,104 @@
+//===--- TestSupport.h - Clang-based refactoring tool ---*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+///
+/// \file
+/// \brief Declares datatypes and routines that are used by test-specific code
+/// in clang-refactor.
+///
+//===--===//
+
+#ifndef LLVM_CLANG_TOOLS_CLANG_REFACTOR_TEST_SUPPORT_H
+#define LLVM_CLANG_TOOLS_CLANG_REFACTOR_TEST_SUPPORT_H
+
+#include "clang/Basic/LLVM.h"
+#include "clang/Basic/SourceLocation.h"
+#include "clang/Tooling/Refactoring/AtomicChange.h"
+#include "llvm/ADT/Optional.h"
+#include "llvm/ADT/SmallVector.h"
+#include "llvm/Support/Error.h"
+#include 
+#include 
+
+namespace clang {
+
+class SourceManager;
+
+namespace clang_refactor {
+
+/// A source selection range that's specified in a test file using an inline
+/// command in the comment. These commands can take the following forms:
+///
+/// - /*range=*/ will create an empty selection range in the default group
+///   right after the comment.
+/// - /*range a=*/ will create an empty selection range in the 'a' group right
+///   after the comment.
+/// - /*range = +1*/ will create an empty selection range at a location that's
+///   right after the comment with one offset to the column.
+/// - /*range= -> +2:3*/ will create a selection range that starts at the
+///   location right after the comment, and ends at column 3 of the 2nd line
+///   after the line of the starting location.
+///
+/// Clang-refactor will expected all ranges in one test group to produce
+/// identical results.
+struct TestSelectionRange {
+  unsigned Begin, End;
+};
+
+/// A set of test selection ranges specified in one file.
+struct TestSelectionRangesInFile {
+  std::string Filename;
+  std::map> GroupedRanges;
+
+ 

[PATCH] D37428: Debug info: Fixed faulty debug locations for attributed statements

2017-09-05 Thread Karl-Johan Karlsson via Phabricator via cfe-commits
Ka-Ka updated this revision to Diff 113803.
Ka-Ka edited the summary of this revision.
Ka-Ka added a reviewer: dblaikie.
Ka-Ka added a comment.

I updated the testcase according to what David Blaikie suggested.
I also rewrote to code to be a bit more robust and avoid emitting unnecessary 
stoppoints.


https://reviews.llvm.org/D37428

Files:
  lib/CodeGen/CGStmt.cpp
  lib/CodeGen/CodeGenFunction.h
  test/CodeGen/debug-info-attributed-stmt.c

Index: test/CodeGen/debug-info-attributed-stmt.c
===
--- /dev/null
+++ test/CodeGen/debug-info-attributed-stmt.c
@@ -0,0 +1,12 @@
+// RUN: %clang_cc1 -triple x86_64-unk-unk -disable-llvm-passes -debug-info-kind=limited -emit-llvm %s -o - | FileCheck %s
+
+void f(_Bool b)
+{
+#pragma nounroll
+  while (b);
+}
+
+// CHECK: br label %while.cond, !dbg ![[NUM:[0-9]+]]
+// CHECK: br i1 %tobool, label %while.body, label %while.end, !dbg ![[NUM]]
+// CHECK: br label %while.cond, !dbg ![[NUM]], !llvm.loop
+// CHECK: ![[NUM]] = !DILocation(line: 6,
Index: lib/CodeGen/CodeGenFunction.h
===
--- lib/CodeGen/CodeGenFunction.h
+++ lib/CodeGen/CodeGenFunction.h
@@ -2534,7 +2534,7 @@
   /// This function may clear the current insertion point; callers should use
   /// EnsureInsertPoint if they wish to subsequently generate code without first
   /// calling EmitBlock, EmitBranch, or EmitStmt.
-  void EmitStmt(const Stmt *S);
+  void EmitStmt(const Stmt *S, ArrayRef Attrs = None);
 
   /// EmitSimpleStmt - Try to emit a "simple" statement which does not
   /// necessarily require an insertion point or debug information; typically
Index: lib/CodeGen/CGStmt.cpp
===
--- lib/CodeGen/CGStmt.cpp
+++ lib/CodeGen/CGStmt.cpp
@@ -45,7 +45,7 @@
   }
 }
 
-void CodeGenFunction::EmitStmt(const Stmt *S) {
+void CodeGenFunction::EmitStmt(const Stmt *S, ArrayRef Attrs) {
   assert(S && "Null statement?");
   PGO.setCurrentStmt(S);
 
@@ -131,16 +131,16 @@
   case Stmt::IndirectGotoStmtClass:
 EmitIndirectGotoStmt(cast(*S)); break;
 
-  case Stmt::IfStmtClass:   EmitIfStmt(cast(*S)); break;
-  case Stmt::WhileStmtClass:EmitWhileStmt(cast(*S));   break;
-  case Stmt::DoStmtClass:   EmitDoStmt(cast(*S)); break;
-  case Stmt::ForStmtClass:  EmitForStmt(cast(*S));   break;
+  case Stmt::IfStmtClass:  EmitIfStmt(cast(*S));  break;
+  case Stmt::WhileStmtClass:   EmitWhileStmt(cast(*S), Attrs); break;
+  case Stmt::DoStmtClass:  EmitDoStmt(cast(*S), Attrs);   break;
+  case Stmt::ForStmtClass: EmitForStmt(cast(*S), Attrs); break;
 
-  case Stmt::ReturnStmtClass:   EmitReturnStmt(cast(*S)); break;
+  case Stmt::ReturnStmtClass:  EmitReturnStmt(cast(*S));  break;
 
-  case Stmt::SwitchStmtClass:   EmitSwitchStmt(cast(*S)); break;
-  case Stmt::GCCAsmStmtClass:   // Intentional fall-through.
-  case Stmt::MSAsmStmtClass:EmitAsmStmt(cast(*S));   break;
+  case Stmt::SwitchStmtClass:  EmitSwitchStmt(cast(*S));  break;
+  case Stmt::GCCAsmStmtClass:  // Intentional fall-through.
+  case Stmt::MSAsmStmtClass:   EmitAsmStmt(cast(*S));break;
   case Stmt::CoroutineBodyStmtClass:
 EmitCoroutineBody(cast(*S));
 break;
@@ -178,7 +178,7 @@
 EmitCXXTryStmt(cast(*S));
 break;
   case Stmt::CXXForRangeStmtClass:
-EmitCXXForRangeStmt(cast(*S));
+EmitCXXForRangeStmt(cast(*S), Attrs);
 break;
   case Stmt::SEHTryStmtClass:
 EmitSEHTryStmt(cast(*S));
@@ -555,23 +555,7 @@
 }
 
 void CodeGenFunction::EmitAttributedStmt(const AttributedStmt ) {
-  const Stmt *SubStmt = S.getSubStmt();
-  switch (SubStmt->getStmtClass()) {
-  case Stmt::DoStmtClass:
-EmitDoStmt(cast(*SubStmt), S.getAttrs());
-break;
-  case Stmt::ForStmtClass:
-EmitForStmt(cast(*SubStmt), S.getAttrs());
-break;
-  case Stmt::WhileStmtClass:
-EmitWhileStmt(cast(*SubStmt), S.getAttrs());
-break;
-  case Stmt::CXXForRangeStmtClass:
-EmitCXXForRangeStmt(cast(*SubStmt), S.getAttrs());
-break;
-  default:
-EmitStmt(SubStmt);
-  }
+  EmitStmt(S.getSubStmt(), S.getAttrs());
 }
 
 void CodeGenFunction::EmitGotoStmt(const GotoStmt ) {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D37454: [coroutines] Make sure auto return type of await_resume is properly handled

2017-09-05 Thread Javed Absar via Phabricator via cfe-commits
javed.absar added inline comments.



Comment at: test/SemaCXX/coroutines.cpp:169
+void check_auto_await_suspend() {
+  co_await auto_await_suspend{}; // OK
+}

maybe change the comment to something more meaningful, or remove it.


https://reviews.llvm.org/D37454



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