Re: [PATCH] D23239: [CUDA] Add __device__ overloads for placement new and delete.

2016-08-08 Thread Justin Lebar via cfe-commits
jlebar added a comment.

In https://reviews.llvm.org/D23239#508863, @tra wrote:

> I think we need to add `noexcept` for these in c++11.


Argh, you are completely right.

Thank you for the review.


https://reviews.llvm.org/D23239



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


Re: [PATCH] D23239: [CUDA] Add __device__ overloads for placement new and delete.

2016-08-08 Thread Justin Lebar via cfe-commits
jlebar updated this revision to Diff 67282.
jlebar added a comment.

Add noexcept.


https://reviews.llvm.org/D23239

Files:
  clang/lib/Headers/__clang_cuda_runtime_wrapper.h

Index: clang/lib/Headers/__clang_cuda_runtime_wrapper.h
===
--- clang/lib/Headers/__clang_cuda_runtime_wrapper.h
+++ clang/lib/Headers/__clang_cuda_runtime_wrapper.h
@@ -312,5 +312,23 @@
 #pragma pop_macro("uint3")
 #pragma pop_macro("__USE_FAST_MATH__")
 
+// Device overrides for placement new and delete.
+#pragma push_macro("CUDA_NOEXCEPT")
+#if __cplusplus >= 201103L
+#define CUDA_NOEXCEPT noexcept
+#else
+#define CUDA_NOEXCEPT
+#endif
+
+__device__ inline void *operator new(__SIZE_TYPE__, void *__ptr) CUDA_NOEXCEPT 
{
+  return __ptr;
+}
+__device__ inline void *operator new[](__SIZE_TYPE__, void *__ptr) 
CUDA_NOEXCEPT {
+  return __ptr;
+}
+__device__ inline void operator delete(void *, void *) CUDA_NOEXCEPT {}
+__device__ inline void operator delete[](void *, void *) CUDA_NOEXCEPT {}
+#pragma pop_macro("CUDA_NOEXCEPT")
+
 #endif // __CUDA__
 #endif // __CLANG_CUDA_RUNTIME_WRAPPER_H__


Index: clang/lib/Headers/__clang_cuda_runtime_wrapper.h
===
--- clang/lib/Headers/__clang_cuda_runtime_wrapper.h
+++ clang/lib/Headers/__clang_cuda_runtime_wrapper.h
@@ -312,5 +312,23 @@
 #pragma pop_macro("uint3")
 #pragma pop_macro("__USE_FAST_MATH__")
 
+// Device overrides for placement new and delete.
+#pragma push_macro("CUDA_NOEXCEPT")
+#if __cplusplus >= 201103L
+#define CUDA_NOEXCEPT noexcept
+#else
+#define CUDA_NOEXCEPT
+#endif
+
+__device__ inline void *operator new(__SIZE_TYPE__, void *__ptr) CUDA_NOEXCEPT {
+  return __ptr;
+}
+__device__ inline void *operator new[](__SIZE_TYPE__, void *__ptr) CUDA_NOEXCEPT {
+  return __ptr;
+}
+__device__ inline void operator delete(void *, void *) CUDA_NOEXCEPT {}
+__device__ inline void operator delete[](void *, void *) CUDA_NOEXCEPT {}
+#pragma pop_macro("CUDA_NOEXCEPT")
+
 #endif // __CUDA__
 #endif // __CLANG_CUDA_RUNTIME_WRAPPER_H__
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D23257: Fix clang-tidy crash when a single fix is applied on multiple files.

2016-08-08 Thread Piotr Padlewski via cfe-commits
Prazek added a subscriber: Prazek.
Prazek added a comment.

I remember that it was pissing me off when I used clang-tidy first time. Thanks 
for fixing that!


https://reviews.llvm.org/D23257



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


Re: [PATCH] D22725: [clang-tidy] Add check 'modernize-use-algorithm'

2016-08-08 Thread Piotr Padlewski via cfe-commits
2016-08-08 8:33 GMT-07:00 Aaron Ballman :

> aaron.ballman added inline comments.
>
> 
> Comment at: clang-tidy/modernize/UseAlgorithmCheck.cpp:59-61
> @@ +58,5 @@
> +  IncludeStyle(utils::IncludeSorter::parseIncludeStyle(
> +  Options.get("IncludeStyle", "llvm"))) {
> +
> +  for (const auto  :
> +   {std::make_pair("memcpy", "std::copy"), {"memset", "std::fill"}}) {
> 
> alexfh wrote:
> > I'm not sure this works on MSVC2013. Could someone try this before
> submitting?
> It does not work in MSVC 2013.
>
> What is the best way to fix it and still have a nice code?


> 
> Comment at: clang-tidy/modernize/UseAlgorithmCheck.cpp:102
> @@ +101,3 @@
> +  assert(it != Replacements.end() &&
> + "Replacements list does not match list of registered matcher
> names");
> +  const std::string ReplacedName = it->second;
> 
> alexfh wrote:
> > Notes are treated completely differently - each note has to be attached
> to a warning.
> >
> > Clang-tidy can only deal with two severity levels of diagnostics:
> "warning" and "error", but it's better to let them be controlled by the
> user via `-warnings-as-errors=` command-line option or the
> `WarningsAsErrors` configuration file option.
> Drat. I am not keen on this being a warning (let alone an error) because
> it really doesn't warn the user against anything bad (the type safety
> argument is tenuous at best), and it's arguable whether this actually
> modernizes code. Do you think there's sufficient utility to this check to
> warrant it being default-enabled as part of the modernize suite? For
> instance, we have 368 instances of memcpy() and 171 instances of
> std::copy() in the LLVM code base, which is an example of a very modern C++
> code base. I'm not opposed to the check, just worried that it will drown
> out diagnostics that have more impact to the user.
>
> I consider memcpy and memset very bugprone. It is very easy to swap
arguments by mistake or pass something with a different type etc. Also it
is easier to understand fill than a memset, so it is easier for
C++ programmers who see any of it first time to get it.
If I would see someone using memcpy or memset in C++ code on the review,
asking to change for the one from the algorithm would be my first comment.

About warnings - well, if someone choose this check to be run, then he
probably wants to get warnings instead of notes. I understand your point,
that maybe we should use something lighter for the "light" mistakes, but
the user is the one that feels if something is bad or not, and he just
choose the check that he thinks it is resonable to run.
I would like to see some proposal how you exactly you would imagine good
warnings, but I don't think we should discuss it in this review. We can
change it after it will be in the trunk.

Also, could you respond in the phabricator? I am not sure how does it work,
but sometimes responding in a mail works fine and there is a comment in
phab, but many times it doesn't appear there.

Piotr


> Repository:
>   rL LLVM
>
> https://reviews.llvm.org/D22725
>
>
>
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[libcxx] r278087 - Remove *super* old test suite results doc for Linux and Windows.

2016-08-08 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Mon Aug  8 22:05:43 2016
New Revision: 278087

URL: http://llvm.org/viewvc/llvm-project?rev=278087=rev
Log:
Remove *super* old test suite results doc for Linux and Windows.

Neither of these results files has been update in years. Linux now has a dozen
or so buildbots tracking it and the Windows results are no longer relevant.
I plan on looking into getting a Windows buildbot going using Appveyor in the
coming days.

Removed:
libcxx/trunk/www/results.Linux.html
libcxx/trunk/www/results.Windows.html
Modified:
libcxx/trunk/www/index.html

Modified: libcxx/trunk/www/index.html
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/www/index.html?rev=278087=278086=278087=diff
==
--- libcxx/trunk/www/index.html (original)
+++ libcxx/trunk/www/index.html Mon Aug  8 22:05:43 2016
@@ -140,11 +140,6 @@
   "C++1z" (probably to be C++17) can be found here.
Implementation of the post-c++14 Technical Specifications is in 
progress. A list of features and
   the current status of these features can be found here.
-   
-   Ports to other platforms are underway. Here are recent test
-   results for Windows
-   and Linux.
-   
 


Build Bots

Removed: libcxx/trunk/www/results.Linux.html
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/www/results.Linux.html?rev=278086=auto
==
--- libcxx/trunk/www/results.Linux.html (original)
+++ libcxx/trunk/www/results.Linux.html (removed)
@@ -1,513 +0,0 @@
-
-
-
-  results.Linux
-
-
-
-All failures in the libc++ test suite will be documented here.
-Note: glibc >= 2.16 is required for full C11 compatibility.
-
-Test Suite Run Information:
-Date: 8/18/2014
-Compiler: Clang Tip-of-Tree (r215809)
-ABI: libc++abi
-C Library: eglibc 2.19
-Platform: x86_64-linux-gnu
-Kernel: 3.13.0-32-generic
-Distribution: Ubuntu 14.04
-Run By: Eric Fiselier (eric at efcs dot ca)
-
-
-Testing Time: 1187.82s
-
-Failing Tests (33):
-libc++ :: 
localization/locale.categories/category.collate/locale.collate.byname/compare.pass.cpp
-- GLIBC's locales collate strings differently. Needs investigation.
-libc++ :: 
localization/locale.categories/category.ctype/locale.ctype.byname/tolower_1.pass.cpp
-- Needs Investigation.
-libc++ :: 
localization/locale.categories/category.ctype/locale.ctype.byname/tolower_many.pass.cpp
-- Idem.
-libc++ :: 
localization/locale.categories/category.ctype/locale.ctype.byname/toupper_1.pass.cpp
-- Idem.
-libc++ :: 
localization/locale.categories/category.ctype/locale.ctype.byname/toupper_many.pass.cpp
-- Idem.
-libc++ :: 
localization/locale.categories/category.ctype/locale.ctype.byname/widen_1.pass.cpp
-- Idem
-libc++ :: 
localization/locale.categories/category.ctype/locale.ctype.byname/widen_many.pass.cpp
-- Idem
-libc++ :: 
localization/locale.categories/category.monetary/locale.money.get/locale.money.get.members/get_long_double_ru_RU.pass.cpp
-- Differences in GLIBC locales. Needs investigation.
-libc++ :: 
localization/locale.categories/category.monetary/locale.money.get/locale.money.get.members/get_long_double_zh_CN.pass.cpp
-- Differences in GLIBC locales. Puts '-' before 'CNY' as opposed to 
after.
-libc++ :: 
localization/locale.categories/category.monetary/locale.money.put/locale.money.put.members/put_long_double_ru_RU.pass.cpp
-- Differences in GLIBC locales. Needs investigation.
-libc++ :: 
localization/locale.categories/category.monetary/locale.money.put/locale.money.put.members/put_long_double_zh_CN.pass.cpp
-- Differences in GLIBC locales. Puts '-' before 'CNY' as opposed to 
after.
-libc++ :: 
localization/locale.categories/category.monetary/locale.moneypunct.byname/decimal_point.pass.cpp
-- Expects ',' for ru_RU but gets '.'.
-libc++ :: 
localization/locale.categories/category.monetary/locale.moneypunct.byname/thousands_sep.pass.cpp
-- Expects ',' for ru_RU but gets '.'.
-libc++ :: 
localization/locale.categories/category.numeric/locale.nm.put/facet.num.put.members/put_long_double.pass.cpp
-- GLIBC puts "+nan" where "nan" is expected.
-libc++ :: 
localization/locale.categories/category.time/locale.time.get.byname/get_date.pass.cpp
-- GLIBC has different locale data for fr_FR, ru_RU and zh_CN.
-  The is also a possible bug in zh_CN tests. Needs investigation.
-libc++ :: 
localization/locale.categories/category.time/locale.time.get.byname/get_date_wide.pass.cpp
-- Idem.
-libc++ :: 
localization/locale.categories/category.time/locale.time.get.byname/get_one.pass.cpp
-- Some test cases are non-portible with GLIBC (include time zone).
-  Other failures related to GLIBC locale data. Needs investigation.
-libc++ :: 

[PATCH] D23293: Some place that could using TargetParser in clang

2016-08-08 Thread jojo.ma via cfe-commits
jojo created this revision.
jojo added a reviewer: rengolin.
jojo added a subscriber: cfe-commits.

Some missing usage of TargetParser in Tools.cpp and Targets.cpp.

https://reviews.llvm.org/D23293

Files:
  lib/Basic/Targets.cpp
  lib/Driver/Tools.cpp

Index: lib/Driver/Tools.cpp
===
--- lib/Driver/Tools.cpp
+++ lib/Driver/Tools.cpp
@@ -7458,11 +7458,14 @@
 
 void darwin::setTripleTypeForMachOArchName(llvm::Triple , StringRef Str) {
   const llvm::Triple::ArchType Arch = getArchTypeForMachOArchName(Str);
+  unsigned ArchKind = llvm::ARM::parseArch(Str);
   T.setArch(Arch);
 
   if (Str == "x86_64h")
 T.setArchName(Str);
-  else if (Str == "armv6m" || Str == "armv7m" || Str == "armv7em") {
+  else if (ArchKind == llvm::ARM::AK_ARMV6M ||
+   ArchKind == llvm::ARM::AK_ARMV7M ||
+   ArchKind == llvm::ARM::AK_ARMV7EM) {
 T.setOS(llvm::Triple::UnknownOS);
 T.setObjectFormat(llvm::Triple::MachO);
   }
Index: lib/Basic/Targets.cpp
===
--- lib/Basic/Targets.cpp
+++ lib/Basic/Targets.cpp
@@ -4874,7 +4874,7 @@
   // the frontend matches that.
   if (Triple.getEnvironment() == llvm::Triple::EABI ||
   Triple.getOS() == llvm::Triple::UnknownOS ||
-  StringRef(CPU).startswith("cortex-m")) {
+  ArchProfile == llvm::ARM::PK_M) {
 setABI("aapcs");
   } else if (Triple.isWatchABI()) {
 setABI("aapcs16");
@@ -5203,7 +5203,7 @@
 if (SoftFloat)
   Builder.defineMacro("__SOFTFP__");
 
-if (CPU == "xscale")
+if (ArchKind == llvm::ARM::AK_XSCALE)
   Builder.defineMacro("__XSCALE__");
 
 if (isThumb()) {


Index: lib/Driver/Tools.cpp
===
--- lib/Driver/Tools.cpp
+++ lib/Driver/Tools.cpp
@@ -7458,11 +7458,14 @@
 
 void darwin::setTripleTypeForMachOArchName(llvm::Triple , StringRef Str) {
   const llvm::Triple::ArchType Arch = getArchTypeForMachOArchName(Str);
+  unsigned ArchKind = llvm::ARM::parseArch(Str);
   T.setArch(Arch);
 
   if (Str == "x86_64h")
 T.setArchName(Str);
-  else if (Str == "armv6m" || Str == "armv7m" || Str == "armv7em") {
+  else if (ArchKind == llvm::ARM::AK_ARMV6M ||
+   ArchKind == llvm::ARM::AK_ARMV7M ||
+   ArchKind == llvm::ARM::AK_ARMV7EM) {
 T.setOS(llvm::Triple::UnknownOS);
 T.setObjectFormat(llvm::Triple::MachO);
   }
Index: lib/Basic/Targets.cpp
===
--- lib/Basic/Targets.cpp
+++ lib/Basic/Targets.cpp
@@ -4874,7 +4874,7 @@
   // the frontend matches that.
   if (Triple.getEnvironment() == llvm::Triple::EABI ||
   Triple.getOS() == llvm::Triple::UnknownOS ||
-  StringRef(CPU).startswith("cortex-m")) {
+  ArchProfile == llvm::ARM::PK_M) {
 setABI("aapcs");
   } else if (Triple.isWatchABI()) {
 setABI("aapcs16");
@@ -5203,7 +5203,7 @@
 if (SoftFloat)
   Builder.defineMacro("__SOFTFP__");
 
-if (CPU == "xscale")
+if (ArchKind == llvm::ARM::AK_XSCALE)
   Builder.defineMacro("__XSCALE__");
 
 if (isThumb()) {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D22904: Fix two bugs for musl-libc on ARM

2016-08-08 Thread Lei Zhang via cfe-commits
zlei added a comment.

@rovka Thanks a lot :)


Repository:
  rL LLVM

https://reviews.llvm.org/D22904



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


[libcxxabi] r278076 - Add lib directory to linker paths when using libunwind

2016-08-08 Thread Petr Hosek via cfe-commits
Author: phosek
Date: Mon Aug  8 19:27:19 2016
New Revision: 278076

URL: http://llvm.org/viewvc/llvm-project?rev=278076=rev
Log:
Add lib directory to linker paths when using libunwind

When using libunwind and not building as standalone project, we
need to add LLVM library directory to the list of linker directories
to ensure it can find libunwind dependency.

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

Modified:
libcxxabi/trunk/src/CMakeLists.txt

Modified: libcxxabi/trunk/src/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/libcxxabi/trunk/src/CMakeLists.txt?rev=278076=278075=278076=diff
==
--- libcxxabi/trunk/src/CMakeLists.txt (original)
+++ libcxxabi/trunk/src/CMakeLists.txt Mon Aug  8 19:27:19 2016
@@ -55,6 +55,9 @@ endif()
 append_if(libraries LIBCXXABI_HAS_C_LIB c)
 
 if (LIBCXXABI_USE_LLVM_UNWINDER)
+  if (NOT LIBCXXABI_BUILT_STANDALONE)
+link_directories(${LLVM_LIBRARY_DIR})
+  endif()
   list(APPEND libraries unwind)
 else()
   append_if(libraries LIBCXXABI_HAS_GCC_S_LIB gcc_s)


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


Re: [libcxx] r273034 - Add Filesystem TS -- Complete

2016-08-08 Thread Bruno Cardoso Lopes via cfe-commits
Ping!

On Thu, Aug 4, 2016 at 8:03 AM, Adrian Prantl  wrote:
>
>> On Aug 3, 2016, at 1:56 PM, Bruno Cardoso Lopes  
>> wrote:
>>
>> Hi Eric,
>>
>> After we upgraded our green dragon bots to El Captain (10.11), the
>> test below started to fail on some of our machines:
>>
>> -- 
>> test/std/experimental/filesystem/fs.op.funcs/fs.op.hard_lk_ct/hard_link_count.pass.cpp
>>
>>  TEST_CASE(hard_link_count_for_directory)
>>  {
>>  uintmax_t DirExpect = 3;
>>  uintmax_t Dir3Expect = 2;
>>  #if defined(__APPLE__)
>>  DirExpect += 2;
>>  Dir3Expect += 1;
>>  #endif
>
> Just as a general code review comment: When committing a platform-specific 
> workaround, I would expect there to be a comment explaining what 
> bug/peculiarity of the platform is being worked around :-)
>
> thanks,
> Adrian
>
>>  TEST_CHECK(hard_link_count(StaticEnv::Dir) == DirExpect);
>>  TEST_CHECK(hard_link_count(StaticEnv::Dir3) == Dir3Expect);
>>
>>  std::error_code ec;
>>  TEST_CHECK(hard_link_count(StaticEnv::Dir, ec) == DirExpect);
>>  TEST_CHECK(hard_link_count(StaticEnv::Dir3, ec) == Dir3Expect);
>>  }
>>
>> You can see the issue in every recent (past 10 days) run on
>> http://lab.llvm.org:8080/green/job/clang-stage1-cmake-RA-expensive/433
>>
>> I noticed that commenting out the snippet around "#if
>> defined(__APPLE__)" would make it work. What's the rationale behind
>> the "#if defined(__APPLE__)" above?
>>
>> Thanks,
>>
>>
>> On Tue, Jun 21, 2016 at 3:03 PM, Eric Fiselier via cfe-commits
>>  wrote:
>>> The issue should be fixed in r273323.
>>>
>>> Thanks for the report and for your patience.
>>>
>>> /Eric
>>>
>>> On Mon, Jun 20, 2016 at 11:27 PM, Eric Fiselier  wrote:

 Hi Artem,

 Sorry for the delay, I've been busy with school all day.
 I'll check in a fix tomorrow morning.

 Sorry again,

 /Eric

 On Mon, Jun 20, 2016 at 2:31 PM, Eric Fiselier  wrote:
>
> Oh shoot, I definitely didn't take that into account. I'll put together a
> fix.
>
> /Eric
>
>
>
> On Mon, Jun 20, 2016 at 2:27 PM, Artem Belevich  wrote:
>>
>> Eric,
>>
>> Some tests appear to fail if the path to the tests' current directory
>> has some symlinks in it.
>> In my case source and build tree are in directory 'work' that's
>> symlinked to from my home directory:
>> /usr/local/home/tra/work -> /work/tra
>>
>> This causes multiple failures in libcxx tests. One example:
>>
>>
>> projects/libcxx/test/std/experimental/filesystem/fs.op.funcs/fs.op.rename/rename.pass.cpp:121
>> 121TEST_CHECK(read_symlink(bad_sym_dest) == dne);
>>
>> dne:
>>
>> /usr/local/home/tra/work/llvm/build/gpu/debug/projects/libcxx/test/filesystem/Output/dynamic_env/test.529143/dne
>> bad_sym_dest:
>>
>> /usr/local/home/tra/work/llvm/build/gpu/debug/projects/libcxx/test/filesystem/Output/dynamic_env/test.529143/bad_sym2
>>
>> These are the paths that traverse the 'work' symlink in my home
>> directory. However, the symlink that we're reading contains physical 
>> path to
>> the directory. While it does link to the right place, it's not the path 
>> the
>> test expects.
>>
>> #readlink
>> /usr/local/home/tra/work/llvm/build/gpu/debug/projects/libcxx/test/filesystem/Output/dynamic_env/test.529143/bad_sym2
>>
>> /work/tra/llvm/build/gpu/debug/projects/libcxx/test/filesystem/Output/dynamic_env/test.529143/dne
>>
>> I think we need to normalize paths before we compare them.
>>
>> --Artem
>>
>>
>> On Sat, Jun 18, 2016 at 12:03 PM, Eric Fiselier via cfe-commits
>>  wrote:
>>>
 I assume the correct way to fix this is to disable
 -Wcovered-switch-default while compiling
 libcxx/src/experimental/filesystem/operations.cpp
>>>
>>> Agreed. Disabled in r273092.
>>>
>>> Thanks for your patience with this latest change,
>>>
>>> /Eric
>>>
>>> On Sat, Jun 18, 2016 at 12:54 PM, Adrian Prantl 
>>> wrote:

 Hello Eric,

 this commit causes new warnings on our bots:

 clang/src/projects/libcxx/include/fstream:816:5: warning: default
 label in switch which covers all enumeration values
 [-Wcovered-switch-default]
default:

 The problem is with this defensive default statement in fstream:


 template 
 0792 typename basic_filebuf<_CharT, _Traits>::pos_type
 0793 basic_filebuf<_CharT, _Traits>::seekoff(off_type __off,
 ios_base::seekdir __way,
 0794 ios_base::openmode)
 0795 {
 0796 #ifndef _LIBCPP_NO_EXCEPTIONS
 

Re: [PATCH] D23236: When ARC is enabled, no warning will be generated when a method1. Returns 'nil' in a method that is attributed to return a 'nonnull'2. The return-statement is a ConditionalOperator

2016-08-08 Thread Devin Coughlin via cfe-commits
dcoughlin added inline comments.


Comment at: test/Analysis/nullability.mm:114
@@ -112,1 +113,3 @@
 
+NSString *_Nonnull testNullReturnInTernaryOperator(int x) {
+return x > 3 ? nil : [@"" stringByAppendingString:@""]; // 
expected-warning {{Null is returned from a function that is expected to return 
a non-null value}}

I think a better file for these two analyzer tests is 
Analysis/nullability_nullonly.mm because they check for flows of nil to 
_Nonnull and not _Nullable to _Nonnull. Also, you shouldn't need to add an 
extra RUN line there.

Long-term these analyzer nullability test files need to be merged, but for this 
change I think sticking the two added tests in nullability_nullonly.mm is the 
best option.




https://reviews.llvm.org/D23236



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


Re: [PATCH] D18073: Add memory allocating functions

2016-08-08 Thread Alexander Riccio via cfe-commits
ariccio added a comment.

In https://reviews.llvm.org/D18073#504216, @dcoughlin wrote:

> No. The identifier info will be null for C++ operators.


I assume you mean `operator new/new[]/delete/delete[]

> > Thus, when`! isWindowsMSVCEnvironment`, I leave the Windows-only memory 
> > allocating functions initialized to `nullptr`, which will never equal a 
> > non-null `IdentifierInfo*`, and never trigger on a non-Windows platform.

> 

> 

> It is probably better to be explicit about this.





https://reviews.llvm.org/D18073



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


Re: [PATCH] D23004: [ASTMatchers] Add matchers canReferToDecl() and hasUnderlyingDecl()

2016-08-08 Thread Alexander Kornienko via cfe-commits
alexfh accepted this revision.
alexfh added a reviewer: alexfh.
alexfh added a comment.

LG


https://reviews.llvm.org/D23004



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


Re: [PATCH] D22725: [clang-tidy] Add check 'modernize-use-algorithm'

2016-08-08 Thread Alexander Kornienko via cfe-commits
alexfh added inline comments.


Comment at: clang-tidy/modernize/UseAlgorithmCheck.cpp:59-61
@@ +58,5 @@
+  IncludeStyle(utils::IncludeSorter::parseIncludeStyle(
+  Options.get("IncludeStyle", "llvm"))) {
+
+  for (const auto  :
+   {std::make_pair("memcpy", "std::copy"), {"memset", "std::fill"}}) {

aaron.ballman wrote:
> alexfh wrote:
> > I'm not sure this works on MSVC2013. Could someone try this before 
> > submitting?
> It does not work in MSVC 2013.
Thanks for verifying. Then it should be just

  Replacements["memcpy"] = "std::copy";
  Replacements["memset"] = "std::fill";

Maybe even remove the map completely and just hardcode the two options in 
`UseAlgorithmCheck::check`. Or are we expecting other similar functions to be 
added to the list? (I guess, unlikely)


Comment at: clang-tidy/modernize/UseAlgorithmCheck.cpp:102
@@ +101,3 @@
+  assert(it != Replacements.end() &&
+ "Replacements list does not match list of registered matcher names");
+  const std::string ReplacedName = it->second;

aaron.ballman wrote:
> alexfh wrote:
> > Notes are treated completely differently - each note has to be attached to 
> > a warning.
> > 
> > Clang-tidy can only deal with two severity levels of diagnostics: "warning" 
> > and "error", but it's better to let them be controlled by the user via 
> > `-warnings-as-errors=` command-line option or the `WarningsAsErrors` 
> > configuration file option.
> Drat. I am not keen on this being a warning (let alone an error) because it 
> really doesn't warn the user against anything bad (the type safety argument 
> is tenuous at best), and it's arguable whether this actually modernizes code. 
> Do you think there's sufficient utility to this check to warrant it being 
> default-enabled as part of the modernize suite? For instance, we have 368 
> instances of memcpy() and 171 instances of std::copy() in the LLVM code base, 
> which is an example of a very modern C++ code base. I'm not opposed to the 
> check, just worried that it will drown out diagnostics that have more impact 
> to the user.
It's a terminology issue, I think. Clang-tidy uses clang "warnings" for all 
kinds of warnings, issues, suggestions or recommendations it reports. If we 
want to extend the range while remaining in the clang  diagnostic engine 
bounds, we could use Remark for some diagnostics, but I think, the mapping 
would still need to be configurable by the user. Alternatively, we could 
introduce some kind of a more granular integer-based severity level. However, I 
don't have an immediate use case for either of these, so I'd leave design to 
someone, who actually needs this and can explain the motivation.


Repository:
  rL LLVM

https://reviews.llvm.org/D22725



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


Re: [clang-tools-extra] r277677 - [clang-tidy] Inefficient string operation

2016-08-08 Thread Alexander Kornienko via cfe-commits
Agreed. Normally, arc copies the full patch description from Phab, but this
time the patch didn't apply cleanly, so I had to copy the commit message by
hand and missed a substantial part of it.

On Mon, Aug 8, 2016 at 5:35 PM, David Blaikie  wrote:

>
>
> On Wed, Aug 3, 2016 at 4:13 PM Alexander Kornienko via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
>
>> Author: alexfh
>> Date: Wed Aug  3 18:06:03 2016
>> New Revision: 277677
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=277677=rev
>> Log:
>> [clang-tidy] Inefficient string operation
>>
>
> A more detailed commit message might be nice. The code review included
> some information that might've been a good start:
>
> "This checker is to warn about the performance overhead caused by
> concatenating strings using the operator+ instead of basic_string's append
> or operator+=. It is configurable. In strict mode it matches every instance
> of a supposed inefficient concatenation, in non-strict mode it matches only
> those which are inside a loop."
>
>
>>
>> Patch by Bittner Barni!
>>
>> Differential revision: https://reviews.llvm.org/D20196
>>
>> Added:
>> clang-tools-extra/trunk/clang-tidy/performance/
>> InefficientStringConcatenationCheck.cpp
>> clang-tools-extra/trunk/clang-tidy/performance/
>> InefficientStringConcatenationCheck.h
>> clang-tools-extra/trunk/docs/clang-tidy/checks/performance-
>> inefficient-string-concatenation.rst
>> clang-tools-extra/trunk/test/clang-tidy/performance-
>> inefficient-string-concatenation.cpp
>> Modified:
>> clang-tools-extra/trunk/clang-tidy/performance/CMakeLists.txt
>> clang-tools-extra/trunk/clang-tidy/performance/
>> PerformanceTidyModule.cpp
>> clang-tools-extra/trunk/docs/ReleaseNotes.rst
>> clang-tools-extra/trunk/docs/clang-tidy/checks/list.rst
>>
>> Modified: clang-tools-extra/trunk/clang-tidy/performance/CMakeLists.txt
>> URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/
>> trunk/clang-tidy/performance/CMakeLists.txt?rev=277677=
>> 277676=277677=diff
>> 
>> ==
>> --- clang-tools-extra/trunk/clang-tidy/performance/CMakeLists.txt
>> (original)
>> +++ clang-tools-extra/trunk/clang-tidy/performance/CMakeLists.txt Wed
>> Aug  3 18:06:03 2016
>> @@ -4,6 +4,7 @@ add_clang_library(clangTidyPerformanceMo
>>FasterStringFindCheck.cpp
>>ForRangeCopyCheck.cpp
>>ImplicitCastInLoopCheck.cpp
>> +  InefficientStringConcatenationCheck.cpp
>>PerformanceTidyModule.cpp
>>UnnecessaryCopyInitialization.cpp
>>UnnecessaryValueParamCheck.cpp
>>
>> Added: clang-tools-extra/trunk/clang-tidy/performance/
>> InefficientStringConcatenationCheck.cpp
>> URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/
>> trunk/clang-tidy/performance/InefficientStringConcatenation
>> Check.cpp?rev=277677=auto
>> 
>> ==
>> --- clang-tools-extra/trunk/clang-tidy/performance/
>> InefficientStringConcatenationCheck.cpp (added)
>> +++ clang-tools-extra/trunk/clang-tidy/performance/
>> InefficientStringConcatenationCheck.cpp Wed Aug  3 18:06:03 2016
>> @@ -0,0 +1,86 @@
>> +//===--- InefficientStringConcatenationCheck.cpp -
>> clang-tidy--===//
>> +//
>> +// The LLVM Compiler Infrastructure
>> +//
>> +// This file is distributed under the University of Illinois Open Source
>> +// License. See LICENSE.TXT for details.
>> +//
>> +//===--
>> ===//
>> +
>> +#include "InefficientStringConcatenationCheck.h"
>> +#include "clang/AST/ASTContext.h"
>> +#include "clang/ASTMatchers/ASTMatchFinder.h"
>> +
>> +using namespace clang::ast_matchers;
>> +
>> +namespace clang {
>> +namespace tidy {
>> +namespace performance {
>> +
>> +void InefficientStringConcatenationCheck::storeOptions(
>> +ClangTidyOptions::OptionMap ) {
>> +  Options.store(Opts, "StrictMode", StrictMode);
>> +}
>> +
>> +InefficientStringConcatenationCheck::InefficientStringConcatenation
>> Check(
>> +StringRef Name, ClangTidyContext *Context)
>> +: ClangTidyCheck(Name, Context), StrictMode(Options.get("StrictMode",
>> 0)) {}
>> +
>> +void InefficientStringConcatenationCheck::registerMatchers(
>> +MatchFinder *Finder) {
>> +  if (!getLangOpts().CPlusPlus)
>> +return;
>> +
>> +  const auto BasicStringType =
>> +  hasType(cxxRecordDecl(hasName("::std::basic_string")));
>> +
>> +  const auto BasicStringPlusOperator = cxxOperatorCallExpr(
>> +  hasOverloadedOperatorName("+"),
>> +  hasAnyArgument(ignoringImpCasts(declRefExpr(BasicStringType;
>> +
>> +  const auto PlusOperator =
>> +  cxxOperatorCallExpr(
>> +  hasOverloadedOperatorName("+"),
>> +  hasAnyArgument(ignoringImpCasts(declRefExpr(
>> BasicStringType))),
>> +  hasDescendant(BasicStringPlusOperator))
>> +  .bind("plusOperator");
>> +

[libcxx] r278068 - Allow building both shared and static library

2016-08-08 Thread Petr Hosek via cfe-commits
Author: phosek
Date: Mon Aug  8 17:57:25 2016
New Revision: 278068

URL: http://llvm.org/viewvc/llvm-project?rev=278068=rev
Log:
Allow building both shared and static library

This change allows building both shared and static version of libc++
in a single build, sharing object files between both versions.

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

Modified:
libcxx/trunk/CMakeLists.txt
libcxx/trunk/docs/BuildingLibcxx.rst
libcxx/trunk/lib/CMakeLists.txt

Modified: libcxx/trunk/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/CMakeLists.txt?rev=278068=278067=278068=diff
==
--- libcxx/trunk/CMakeLists.txt (original)
+++ libcxx/trunk/CMakeLists.txt Mon Aug  8 17:57:25 2016
@@ -52,6 +52,7 @@ MACRO_ENSURE_OUT_OF_SOURCE_BUILD(
 # Basic options ---
 option(LIBCXX_ENABLE_ASSERTIONS "Enable assertions independent of build mode." 
ON)
 option(LIBCXX_ENABLE_SHARED "Build libc++ as a shared library." ON)
+option(LIBCXX_ENABLE_STATIC "Build libc++ as a static library." ON)
 option(LIBCXX_ENABLE_EXPERIMENTAL_LIBRARY "Build libc++experimental.a" ON)
 option(LIBCXX_ENABLE_FILESYSTEM
 "Build filesystem as part of libc++experimental.a" 
${LIBCXX_ENABLE_EXPERIMENTAL_LIBRARY})
@@ -68,6 +69,10 @@ option(LIBCXX_INSTALL_EXPERIMENTAL_LIBRA
 set(LIBCXX_ABI_VERSION 1 CACHE STRING "ABI version of libc++.")
 option(LIBCXX_ABI_UNSTABLE "Unstable ABI of libc++." OFF)
 
+if (NOT LIBCXX_ENABLE_SHARED AND NOT LIBCXX_ENABLE_STATIC)
+  message(FATAL_ERROR "libc++ must be built as either a shared or static 
library.")
+endif()
+
 # ABI Library options -
 set(LIBCXX_CXX_ABI "${LIBCXX_CXX_ABI}" CACHE STRING
 "Specify C++ ABI library to use." FORCE)

Modified: libcxx/trunk/docs/BuildingLibcxx.rst
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/docs/BuildingLibcxx.rst?rev=278068=278067=278068=diff
==
--- libcxx/trunk/docs/BuildingLibcxx.rst (original)
+++ libcxx/trunk/docs/BuildingLibcxx.rst Mon Aug  8 17:57:25 2016
@@ -150,8 +150,15 @@ libc++ specific options
 
   **Default**: ``ON``
 
-  Build libc++ as a shared library. If ``OFF`` is specified then libc++ is
-  built as a static library.
+  Build libc++ as a shared library. Either :option:`LIBCXX_ENABLE_SHARED` or
+  :option:`LIBCXX_ENABLE_STATIC` has to be enabled.
+
+.. option:: LIBCXX_ENABLE_STATIC:BOOL
+
+  **Default**: ``ON``
+
+  Build libc++ as a static library. Either :option:`LIBCXX_ENABLE_SHARED` or
+  :option:`LIBCXX_ENABLE_STATIC` has to be enabled.
 
 .. option:: LIBCXX_LIBDIR_SUFFIX:STRING
 

Modified: libcxx/trunk/lib/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/lib/CMakeLists.txt?rev=278068=278067=278068=diff
==
--- libcxx/trunk/lib/CMakeLists.txt (original)
+++ libcxx/trunk/lib/CMakeLists.txt Mon Aug  8 17:57:25 2016
@@ -28,16 +28,6 @@ if(NOT LIBCXX_INSTALL_LIBRARY)
   set(exclude_from_all EXCLUDE_FROM_ALL)
 endif()
 
-if (LIBCXX_ENABLE_SHARED)
-  add_library(cxx SHARED ${exclude_from_all} ${LIBCXX_SOURCES} 
${LIBCXX_HEADERS})
-else()
-  add_library(cxx STATIC ${exclude_from_all} ${LIBCXX_SOURCES} 
${LIBCXX_HEADERS})
-endif()
-
-if (DEFINED LIBCXX_CXX_ABI_DEPS)
-  add_dependencies(cxx LIBCXX_CXX_ABI_DEPS)
-endif()
-
 #if LIBCXX_CXX_ABI_LIBRARY_PATH is defined we want to add it to the search 
path.
 add_link_flags_if(LIBCXX_CXX_ABI_LIBRARY_PATH 
"-L${LIBCXX_CXX_ABI_LIBRARY_PATH}")
 
@@ -139,18 +129,51 @@ if ( APPLE AND (LIBCXX_CXX_ABI_LIBNAME S
   endif()
 endif()
 
-target_link_libraries(cxx ${LIBCXX_LIBRARIES})
 split_list(LIBCXX_COMPILE_FLAGS)
 split_list(LIBCXX_LINK_FLAGS)
 
-set_target_properties(cxx
+# Add a object library that contains the compiled source files.
+add_library(cxx_objects OBJECT ${exclude_from_all} ${LIBCXX_SOURCES} 
${LIBCXX_HEADERS})
+
+set_target_properties(cxx_objects
   PROPERTIES
 COMPILE_FLAGS "${LIBCXX_COMPILE_FLAGS}"
-LINK_FLAGS"${LIBCXX_LINK_FLAGS}"
-OUTPUT_NAME   "c++"
-VERSION   "${LIBCXX_ABI_VERSION}.0"
-SOVERSION "${LIBCXX_ABI_VERSION}"
+)
+
+set(LIBCXX_TARGETS)
+
+# Build the shared library.
+if (LIBCXX_ENABLE_SHARED)
+  add_library(cxx_shared SHARED $)
+  target_link_libraries(cxx_shared ${LIBCXX_LIBRARIES})
+  set_target_properties(cxx_shared
+PROPERTIES
+  LINK_FLAGS"${LIBCXX_LINK_FLAGS}"
+  OUTPUT_NAME   "c++"
+  VERSION   "${LIBCXX_ABI_VERSION}.0"
+  SOVERSION "${LIBCXX_ABI_VERSION}"
   )
+  list(APPEND LIBCXX_TARGETS "cxx_shared")
+endif()
+
+# Build the static library.
+if (LIBCXX_ENABLE_STATIC)
+  add_library(cxx_static STATIC $)
+  target_link_libraries(cxx_static ${LIBCXX_LIBRARIES})
+  set_target_properties(cxx_static
+PROPERTIES
+ 

[libunwind] r278067 - Allow building both shared and static library

2016-08-08 Thread Petr Hosek via cfe-commits
Author: phosek
Date: Mon Aug  8 17:55:48 2016
New Revision: 278067

URL: http://llvm.org/viewvc/llvm-project?rev=278067=rev
Log:
Allow building both shared and static library

This change allows building both shared and static version of libunwind
in a single build, sharing object files between both versions.

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

Modified:
libunwind/trunk/CMakeLists.txt
libunwind/trunk/src/CMakeLists.txt

Modified: libunwind/trunk/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/libunwind/trunk/CMakeLists.txt?rev=278067=278066=278067=diff
==
--- libunwind/trunk/CMakeLists.txt (original)
+++ libunwind/trunk/CMakeLists.txt Mon Aug  8 17:55:48 2016
@@ -104,6 +104,7 @@ option(LIBUNWIND_ENABLE_ASSERTIONS "Enab
 option(LIBUNWIND_ENABLE_PEDANTIC "Compile with pedantic enabled." ON)
 option(LIBUNWIND_ENABLE_WERROR "Fail and stop if a warning is triggered." OFF)
 option(LIBUNWIND_ENABLE_SHARED "Build libunwind as a shared library." ON)
+option(LIBUNWIND_ENABLE_STATIC "Build libunwind as a static library." ON)
 option(LIBUNWIND_ENABLE_CROSS_UNWINDING "Enable cross-platform unwinding 
support." OFF)
 option(LIBUNWIND_ENABLE_ARM_WMMX "Enable unwinding support for ARM WMMX 
registers." OFF)
 
@@ -111,6 +112,10 @@ set(LIBUNWIND_TARGET_TRIPLE "" CACHE STR
 set(LIBUNWIND_GCC_TOOLCHAIN "" CACHE PATH "GCC toolchain for cross compiling.")
 set(LIBUNWIND_SYSROOT "" CACHE PATH "Sysroot for cross compiling.")
 
+if (NOT LIBUNWIND_ENABLE_SHARED AND NOT LIBUNWIND_ENABLE_STATIC)
+  message(FATAL_ERROR "libunwind must be built as either a shared or static 
library.")
+endif()
+
 # Check that we can build with 32 bits if requested.
 if (CMAKE_SIZEOF_VOID_P EQUAL 8 AND NOT WIN32)
   if (LIBUNWIND_BUILD_32_BITS AND NOT LLVM_BUILD_32_BITS) # Don't duplicate 
the output from LLVM

Modified: libunwind/trunk/src/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/libunwind/trunk/src/CMakeLists.txt?rev=278067=278066=278067=diff
==
--- libunwind/trunk/src/CMakeLists.txt (original)
+++ libunwind/trunk/src/CMakeLists.txt Mon Aug  8 17:55:48 2016
@@ -49,20 +49,12 @@ set(LIBUNWIND_SOURCES
 ${LIBUNWIND_C_SOURCES}
 ${LIBUNWIND_ASM_SOURCES})
 
-if (LIBUNWIND_ENABLE_SHARED)
-  add_library(unwind SHARED ${LIBUNWIND_SOURCES} ${LIBUNWIND_HEADERS})
-else()
-  add_library(unwind STATIC ${LIBUNWIND_SOURCES} ${LIBUNWIND_HEADERS})
-endif ()
-
 # Generate library list.
 set(libraries ${LIBUNWINDCXX_ABI_LIBRARIES})
 append_if(libraries LIBUNWIND_HAS_C_LIB c)
 append_if(libraries LIBUNWIND_HAS_DL_LIB dl)
 append_if(libraries LIBUNWIND_HAS_PTHREAD_LIB pthread)
 
-target_link_libraries(unwind ${libraries})
-
 # Setup flags.
 append_if(LIBUNWIND_COMPILE_FLAGS LIBUNWIND_HAS_FPIC_FLAG -fPIC)
 append_if(LIBUNWIND_CXX_FLAGS LIBUNWIND_HAS_NO_RTTI_FLAG -fno-rtti)
@@ -97,19 +89,48 @@ string(REPLACE ";" " " LIBUNWIND_CXX_FLA
 string(REPLACE ";" " " LIBUNWIND_C_FLAGS "${LIBUNWIND_C_FLAGS}")
 string(REPLACE ";" " " LIBUNWIND_LINK_FLAGS "${LIBUNWIND_LINK_FLAGS}")
 
-set_target_properties(unwind
-  PROPERTIES
-COMPILE_FLAGS "${LIBUNWIND_COMPILE_FLAGS}"
-LINK_FLAGS"${LIBUNWIND_LINK_FLAGS}"
-OUTPUT_NAME   "unwind"
-VERSION   "1.0"
-SOVERSION "1")
 set_property(SOURCE ${LIBUNWIND_CXX_SOURCES}
  APPEND_STRING PROPERTY COMPILE_FLAGS " ${CMAKE_CXX_FLAGS} 
${LIBUNWIND_CXX_FLAGS}")
 set_property(SOURCE ${LIBUNWIND_C_SOURCES}
  APPEND_STRING PROPERTY COMPILE_FLAGS " ${CMAKE_C_FLAGS} 
${LIBUNWIND_C_FLAGS}")
 
-install(TARGETS unwind
+# Add a object library that contains the compiled source files.
+add_library(unwind_objects OBJECT ${LIBUNWIND_SOURCES} ${LIBUNWIND_HEADERS})
+
+set_target_properties(unwind_objects
+  PROPERTIES
+COMPILE_FLAGS "${LIBUNWIND_COMPILE_FLAGS}")
+
+set(LIBUNWIND_TARGETS)
+
+# Build the shared library.
+if (LIBUNWIND_ENABLE_SHARED)
+  add_library(unwind_shared SHARED $)
+  target_link_libraries(unwind_shared ${libraries})
+  set_target_properties(unwind_shared
+PROPERTIES
+  LINK_FLAGS"${LIBUNWIND_LINK_FLAGS}"
+  OUTPUT_NAME   "unwind"
+  VERSION   "1.0"
+  SOVERSION "1")
+  list(APPEND LIBUNWIND_TARGETS "unwind_shared")
+endif()
+
+# Build the static library.
+if (LIBUNWIND_ENABLE_STATIC)
+  add_library(unwind_static STATIC $)
+  target_link_libraries(unwind_static ${libraries})
+  set_target_properties(unwind_static
+PROPERTIES
+  LINK_FLAGS"${LIBUNWIND_LINK_FLAGS}"
+  OUTPUT_NAME   "unwind")
+  list(APPEND LIBUNWIND_TARGETS 

[PATCH] D23284: Add -Rpass-with-hotness

2016-08-08 Thread Adam Nemet via cfe-commits
anemet created this revision.
anemet added reviewers: hfinkel, rjmccall, aaron.ballman.
anemet added a subscriber: cfe-commits.

I've recently added the ability for optimization remarks to include the
hotness of the corresponding code region.  This uses PGO and allows
filtering of the optimization remarks by relevance.  The idea was first
discussed here:
http://thread.gmane.org/gmane.comp.compilers.llvm.devel/98334

The general goal is to produce a YAML file with the remarks.  Then, an
external tool could dynamically filter these by hotness and perhaps by
other things.

That said it makes sense to also expose this at the more basic level
where we just include the hotness info with each optimization remark.
For example, in D22694, the clang flag was pretty useful to measure the
overhead of the additional analyses required to include hotness.
(Without the flag we don't even run the analyses.)

For the record, Hal has already expressed support for the idea of this
patch on IRC.

I didn't make -R{,no-}pass-with-hotness member of Group.
I *think* that this is right because unlike other -Rpass flags this one
does not enable any remark group, so it shouldn't be processed by
ProcessWarningOptions.

https://reviews.llvm.org/D23284

Files:
  include/clang/Basic/DiagnosticDriverKinds.td
  include/clang/Driver/Options.td
  include/clang/Frontend/CodeGenOptions.def
  lib/CodeGen/CodeGenAction.cpp
  lib/Frontend/CompilerInvocation.cpp
  test/Frontend/Inputs/optimization-remark-with-hotness.proftext
  test/Frontend/optimization-remark-with-hotness.c

Index: test/Frontend/optimization-remark-with-hotness.c
===
--- /dev/null
+++ test/Frontend/optimization-remark-with-hotness.c
@@ -0,0 +1,41 @@
+// RUN: llvm-profdata merge \
+// RUN: %S/Inputs/optimization-remark-with-hotness.proftext   \
+// RUN: -o %t.profdata
+// RUN: %clang_cc1 -triple x86_64-apple-macosx10.9 -main-file-name \
+// RUN: optimization-remark-with-hotness.c %s -emit-llvm-only \
+// RUN: -fprofile-instrument-use-path=%t.profdata -Rpass=inline \
+// RUN: -Rpass-analysis=inline -Rpass-with-hotness -verify
+// RUN: %clang_cc1 -triple x86_64-apple-macosx10.9 -main-file-name \
+// RUN: optimization-remark-with-hotness.c %s -emit-llvm-only \
+// RUN: -fprofile-instrument-use-path=%t.profdata -Rpass=inline \
+// RUN: -Rpass-analysis=inline 2>&1 | FileCheck -check-prefix=HOTNESS_OFF %s
+// RUN: %clang_cc1 -triple x86_64-apple-macosx10.9 -main-file-name \
+// RUN: optimization-remark-with-hotness.c %s -emit-llvm-only \
+// RUN: -fprofile-instrument-use-path=%t.profdata -Rpass=inline \
+// RUN: -Rpass-analysis=inline -Rno-pass-with-hotness  2>&1 | FileCheck \
+// RUN: -check-prefix=HOTNESS_OFF %s
+// RUN: %clang_cc1 -triple x86_64-apple-macosx10.9 -main-file-name \
+// RUN: optimization-remark-with-hotness.c %s -emit-llvm-only \
+// RUN: -Rpass=inline -Rpass-analysis=inline -Rpass-with-hotness  2>&1 \
+// RUN: | FileCheck -check-prefix=NO_PGO %s
+
+int foo(int x, int y) __attribute__((always_inline));
+int foo(int x, int y) { return x + y; }
+
+int sum = 0;
+
+void bar(int x) {
+  // HOTNESS_OFF: foo inlined into bar
+  // HOTNESS_OFF-NOT: hotness:
+  // NO_PGO: '-Rpass-with-hotness' requires profile information
+  // expected-remark@+2 {{foo should always be inlined (cost=always) (hotness: 30)}}
+  // expected-remark@+1 {{foo inlined into bar (hotness: 30)}}
+  sum += foo(x, x - 2);
+}
+
+int main(int argc, const char *argv[]) {
+  for (int i = 0; i < 30; i++)
+// expected-remark@+1 {{bar should never be inlined}}
+bar(argc);
+  return sum;
+}
Index: test/Frontend/Inputs/optimization-remark-with-hotness.proftext
===
--- /dev/null
+++ test/Frontend/Inputs/optimization-remark-with-hotness.proftext
@@ -0,0 +1,25 @@
+foo
+# Func Hash:
+0
+# Num Counters:
+1
+# Counter Values:
+30
+
+bar
+# Func Hash:
+0
+# Num Counters:
+1
+# Counter Values:
+30
+
+main
+# Func Hash:
+4
+# Num Counters:
+2
+# Counter Values:
+1
+30
+
Index: lib/Frontend/CompilerInvocation.cpp
===
--- lib/Frontend/CompilerInvocation.cpp
+++ lib/Frontend/CompilerInvocation.cpp
@@ -818,6 +818,14 @@
 NeedLocTracking = true;
   }
 
+  Opts.PassRemarksWithHotness =
+  Args.hasFlag(options::OPT_Rpass_with_hotness,
+   options::OPT_Rno_pass_with_hotness, /*default*/ false);
+  if (Opts.PassRemarksWithHotness &&
+  Opts.getProfileUse() == CodeGenOptions::ProfileNone)
+Diags.Report(diag::warn_drv_argument_requires) << "-Rpass-with-hotness"
+   << "profile information";
+
   // If the user requested to use a sample profile for PGO, then the
   // backend will need to track source location information so the profile
   // can be incorporated into the IR.
Index: 

[libcxxabi] r278058 - Do not depend on unwind when building standalone

2016-08-08 Thread Petr Hosek via cfe-commits
Author: phosek
Date: Mon Aug  8 17:09:54 2016
New Revision: 278058

URL: http://llvm.org/viewvc/llvm-project?rev=278058=rev
Log:
Do not depend on unwind when building standalone

When libcxxabi is being built standalone, unwind dependency is not
available, so do not use it even when LLVM unwinder is being
requested.

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

Modified:
libcxxabi/trunk/test/CMakeLists.txt

Modified: libcxxabi/trunk/test/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/libcxxabi/trunk/test/CMakeLists.txt?rev=278058=278057=278058=diff
==
--- libcxxabi/trunk/test/CMakeLists.txt (original)
+++ libcxxabi/trunk/test/CMakeLists.txt Mon Aug  8 17:09:54 2016
@@ -36,10 +36,9 @@ endif()
 
 if (NOT LIBCXXABI_BUILT_STANDALONE)
   list(APPEND LIBCXXABI_TEST_DEPS cxx)
-endif()
-
-if (LIBCXXABI_USE_LLVM_UNWINDER)
-  list(APPEND LIBCXXABI_TEST_DEPS unwind)
+  if (LIBCXXABI_USE_LLVM_UNWINDER)
+list(APPEND LIBCXXABI_TEST_DEPS unwind)
+  endif()
 endif()
 
 add_lit_testsuite(check-libcxxabi "Running libcxxabi tests"


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


Re: [PATCH] D23257: Fix clang-tidy crash when a single fix is applied on multiple files.

2016-08-08 Thread Alexander Kornienko via cfe-commits
alexfh accepted this revision.
alexfh added a comment.
This revision is now accepted and ready to land.

A bunch of nits. Otherwise looks good.

Thank you for the fix!



Comment at: clang-tidy/ClangTidy.cpp:519
@@ -513,2 +518,3 @@
   tooling::TranslationUnitReplacements TUR;
   for (const ClangTidyError  : Errors)
+for (const auto  : Error.Fix)

Please add braces for the outer loop.


Comment at: clang-tidy/ClangTidyDiagnosticConsumer.cpp:81
@@ -82,1 +80,3 @@
+  tooling::Replacement Replacement(SM, Range, FixIt.CodeToInsert);
+  auto Err = Error.Fix[Replacement.getFilePath()].add(Replacement);
   // FIXME: better error handling.

I was kind of intrigued by what `auto` stands for here. I think, `llvm::Error` 
is a less mysterious way of storing an error here ;)


Comment at: clang-tidy/ClangTidyDiagnosticConsumer.cpp:498
@@ -497,3 +497,3 @@
 int Size = 0;
-for (const auto  : Error.Fix)
-  Size += Replace.getLength();
+for (const auto  : Error.Fix)
+  for (const auto  : FileAndReplaces.second)

Please add braces around the outer loop.


Comment at: clang-tidy/ClangTidyDiagnosticConsumer.cpp:506
@@ -504,15 +505,3 @@
   std::map FileEvents;
-  for (unsigned I = 0; I < Errors.size(); ++I) {
-for (const auto  : Errors[I].Fix) {
-  unsigned Begin = Replace.getOffset();
-  unsigned End = Begin + Replace.getLength();
-  const std::string  = Replace.getFilePath();
-  // FIXME: Handle empty intervals, such as those from insertions.
-  if (Begin == End)
-continue;
-  FileEvents[FilePath].push_back(
-  Event(Begin, End, Event::ET_Begin, I, Sizes[I]));
-  FileEvents[FilePath].push_back(
-  Event(Begin, End, Event::ET_End, I, Sizes[I]));
-}
-  }
+  for (unsigned I = 0; I < Errors.size(); ++I)
+for (const auto  : Errors[I].Fix)

Please add braces for both outer loops.


Comment at: unittests/clang-tidy/ClangTidyTest.h:122
@@ -121,7 +121,3 @@
   for (const ClangTidyError  : Context.getErrors())
-for (const auto  : Error.Fix) {
-  auto Err = Fixes.add(Fix);
-  // FIXME: better error handling. Keep the behavior for now.
-  if (Err) {
-llvm::errs() << llvm::toString(std::move(Err)) << "\n";
-return "";
+for (const auto  : Error.Fix)
+  for (const auto  : FileAndFixes.second) {

Please add braces here as well.


https://reviews.llvm.org/D23257



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


Re: [PATCH] D23158: [clang-rename] merge tests when possible

2016-08-08 Thread Alexander Kornienko via cfe-commits
alexfh requested changes to this revision.
alexfh added a comment.
This revision now requires changes to proceed.

Removing from my dashboard until the comments are addressed.


https://reviews.llvm.org/D23158



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


Re: [PATCH] D23193: [clang-rename] fix bug with initializer lists

2016-08-08 Thread Alexander Kornienko via cfe-commits
alexfh accepted this revision.
alexfh added a comment.
This revision is now accepted and ready to land.

The test is fine now. Looks good once the other comment is addressed.


https://reviews.llvm.org/D23193



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


Re: [PATCH] D23244: [Driver] Enable CFI for WebAssembly

2016-08-08 Thread Dominic Chen via cfe-commits
ddcc added a comment.

Can you land it? I don't have commit access.


https://reviews.llvm.org/D23244



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


r278052 - Revert "[Attr] Add support for the `ms_hook_prologue` attribute."

2016-08-08 Thread Charles Davis via cfe-commits
Author: cdavis
Date: Mon Aug  8 16:19:08 2016
New Revision: 278052

URL: http://llvm.org/viewvc/llvm-project?rev=278052=rev
Log:
Revert "[Attr] Add support for the `ms_hook_prologue` attribute."

This reverts commit r278050. It depends on r278048, which will be
reverted.

Removed:
cfe/trunk/test/Sema/attr-ms-hook-prologue-wrong-arch.c
cfe/trunk/test/Sema/attr-ms-hook-prologue.c
Modified:
cfe/trunk/include/clang/Basic/Attr.td
cfe/trunk/include/clang/Basic/AttrDocs.td
cfe/trunk/lib/CodeGen/TargetInfo.cpp
cfe/trunk/lib/Sema/SemaDeclAttr.cpp
cfe/trunk/test/CodeGen/function-attributes.c

Modified: cfe/trunk/include/clang/Basic/Attr.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Attr.td?rev=278052=278051=278052=diff
==
--- cfe/trunk/include/clang/Basic/Attr.td (original)
+++ cfe/trunk/include/clang/Basic/Attr.td Mon Aug  8 16:19:08 2016
@@ -257,7 +257,6 @@ def TargetMips : TargetArch<["mips", "mi
 def TargetMSP430 : TargetArch<["msp430"]>;
 def TargetX86 : TargetArch<["x86"]>;
 def TargetAnyX86 : TargetArch<["x86", "x86_64"]>;
-def TargetWindowsArches : TargetArch<["x86", "x86_64", "arm", "thumb"]>;
 def TargetWindows : TargetArch<["x86", "x86_64", "arm", "thumb"]> {
   let OSes = ["Win32"];
 }
@@ -2070,12 +2069,6 @@ def TypeTagForDatatype : InheritableAttr
 
 // Microsoft-related attributes
 
-def MSHookPrologue : InheritableAttr, TargetSpecificAttr {
-  let Spellings = [GCC<"ms_hook_prologue">];
-  let Subjects = SubjectList<[Function]>;
-  let Documentation = [MSHookPrologueDocs];
-}
-
 def MSNoVTable : InheritableAttr, TargetSpecificAttr {
   let Spellings = [Declspec<"novtable">];
   let Subjects = SubjectList<[CXXRecord]>;

Modified: cfe/trunk/include/clang/Basic/AttrDocs.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/AttrDocs.td?rev=278052=278051=278052=diff
==
--- cfe/trunk/include/clang/Basic/AttrDocs.td (original)
+++ cfe/trunk/include/clang/Basic/AttrDocs.td Mon Aug  8 16:19:08 2016
@@ -548,22 +548,6 @@ Query for this feature with ``__has_attr
   }];
 }
 
-def MSHookPrologueDocs : Documentation {
-  let Category = DocCatFunction;
-  let Content = [{
-The ``ms_hook_prologue`` attribute marks a function as "hotpatchable" according
-to conventions used on Windows. Specifically, enough space will be ensured
-in the prologue for a short jump, and an architecturally dependently sized
-patch space will be reserved prior to the entry point. See the documentation
-for the `/HOTPATCH`_ switch on MSDN.
-
-This attribute cannot be used in conjunction with the ``naked``,
-``always_inline``, or ``__forceinline`` attributes.
-
-.. _`/HOTPATCH`: https://msdn.microsoft.com/en-us/library/ms173507.aspx
-  }];
-}
-
 def NoDebugDocs : Documentation {
   let Category = DocCatVariable;
   let Content = [{

Modified: cfe/trunk/lib/CodeGen/TargetInfo.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/TargetInfo.cpp?rev=278052=278051=278052=diff
==
--- cfe/trunk/lib/CodeGen/TargetInfo.cpp (original)
+++ cfe/trunk/lib/CodeGen/TargetInfo.cpp Mon Aug  8 16:19:08 2016
@@ -1779,10 +1779,6 @@ void X86_32TargetCodeGenInfo::setTargetA
   llvm::Function *Fn = cast(GV);
   Fn->setCallingConv(llvm::CallingConv::X86_INTR);
 }
-if (FD->hasAttr()) {
-  llvm::Function *Fn = cast(GV);
-  Fn->addFnAttr("patchable-function", "ms-hotpatch");
-}
   }
 }
 
@@ -2113,10 +2109,6 @@ public:
 llvm::Function *Fn = cast(GV);
 Fn->setCallingConv(llvm::CallingConv::X86_INTR);
   }
-  if (FD->hasAttr()) {
-llvm::Function *Fn = cast(GV);
-Fn->addFnAttr("patchable-function", "ms-hotpatch");
-  }
 }
   }
 };

Modified: cfe/trunk/lib/Sema/SemaDeclAttr.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclAttr.cpp?rev=278052=278051=278052=diff
==
--- cfe/trunk/lib/Sema/SemaDeclAttr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclAttr.cpp Mon Aug  8 16:19:08 2016
@@ -1664,6 +1664,15 @@ static void handleCommonAttr(Sema , De
 D->addAttr(CA);
 }
 
+static void handleNakedAttr(Sema , Decl *D, const AttributeList ) {
+  if (checkAttrMutualExclusion(S, D, Attr.getRange(),
+ Attr.getName()))
+return;
+
+  D->addAttr(::new (S.Context) NakedAttr(Attr.getRange(), S.Context,
+ 
Attr.getAttributeSpellingListIndex()));
+}
+
 static void handleNoReturnAttr(Sema , Decl *D, const AttributeList ) {
   if (hasDeclarator(D)) return;
 
@@ -3664,9 +3673,7 @@ OptimizeNoneAttr *Sema::mergeOptimizeNon
 static void handleAlwaysInlineAttr(Sema , Decl *D,
const 

Re: [PATCH] D23279: clang-reorder-fields

2016-08-08 Thread Eugene Zelenko via cfe-commits
Eugene.Zelenko added a comment.

I would prefer CMake option to link rarely used tools (list should be 
adjustable) with libclang, which contain a lot of LLVM/Clang code already.


Repository:
  rL LLVM

https://reviews.llvm.org/D23279



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


Re: [PATCH] D23244: [Driver] Enable CFI for WebAssembly

2016-08-08 Thread Derek Schuff via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL278051: [Driver] Enable CFI for WebAssembly (authored by 
dschuff).

Changed prior to commit:
  https://reviews.llvm.org/D23244?vs=67090=67226#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D23244

Files:
  cfe/trunk/lib/Driver/ToolChain.cpp

Index: cfe/trunk/lib/Driver/ToolChain.cpp
===
--- cfe/trunk/lib/Driver/ToolChain.cpp
+++ cfe/trunk/lib/Driver/ToolChain.cpp
@@ -697,7 +697,9 @@
   SanitizerMask Res = (Undefined & ~Vptr & ~Function) | (CFI & ~CFIICall) |
   CFICastStrict | UnsignedIntegerOverflow | LocalBounds;
   if (getTriple().getArch() == llvm::Triple::x86 ||
-  getTriple().getArch() == llvm::Triple::x86_64)
+  getTriple().getArch() == llvm::Triple::x86_64 ||
+  getTriple().getArch() == llvm::Triple::wasm32 ||
+  getTriple().getArch() == llvm::Triple::wasm64)
 Res |= CFIICall;
   return Res;
 }


Index: cfe/trunk/lib/Driver/ToolChain.cpp
===
--- cfe/trunk/lib/Driver/ToolChain.cpp
+++ cfe/trunk/lib/Driver/ToolChain.cpp
@@ -697,7 +697,9 @@
   SanitizerMask Res = (Undefined & ~Vptr & ~Function) | (CFI & ~CFIICall) |
   CFICastStrict | UnsignedIntegerOverflow | LocalBounds;
   if (getTriple().getArch() == llvm::Triple::x86 ||
-  getTriple().getArch() == llvm::Triple::x86_64)
+  getTriple().getArch() == llvm::Triple::x86_64 ||
+  getTriple().getArch() == llvm::Triple::wasm32 ||
+  getTriple().getArch() == llvm::Triple::wasm64)
 Res |= CFIICall;
   return Res;
 }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r278051 - [Driver] Enable CFI for WebAssembly

2016-08-08 Thread Derek Schuff via cfe-commits
Author: dschuff
Date: Mon Aug  8 16:14:15 2016
New Revision: 278051

URL: http://llvm.org/viewvc/llvm-project?rev=278051=rev
Log:
[Driver] Enable CFI for WebAssembly

Since CFI support has landed in the WebAssembly backend, enable it in
the frontend driver.

Patch by Dominic Chen

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

Modified:
cfe/trunk/lib/Driver/ToolChain.cpp

Modified: cfe/trunk/lib/Driver/ToolChain.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChain.cpp?rev=278051=278050=278051=diff
==
--- cfe/trunk/lib/Driver/ToolChain.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChain.cpp Mon Aug  8 16:14:15 2016
@@ -697,7 +697,9 @@ SanitizerMask ToolChain::getSupportedSan
   SanitizerMask Res = (Undefined & ~Vptr & ~Function) | (CFI & ~CFIICall) |
   CFICastStrict | UnsignedIntegerOverflow | LocalBounds;
   if (getTriple().getArch() == llvm::Triple::x86 ||
-  getTriple().getArch() == llvm::Triple::x86_64)
+  getTriple().getArch() == llvm::Triple::x86_64 ||
+  getTriple().getArch() == llvm::Triple::wasm32 ||
+  getTriple().getArch() == llvm::Triple::wasm64)
 Res |= CFIICall;
   return Res;
 }


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


Re: [PATCH] D23279: clang-reorder-fields

2016-08-08 Thread Saleem Abdulrasool via cfe-commits
compnerd added a comment.

This isn't really a renaming tool per se.  If you squint really hard, yes, it 
does rename fields.  But, if we really want to save space, perhaps we should 
collapse all the tools into `clang-tidy` or create a new `clang-refactor` tool 
and just make the other things a part of that tool in various modes (rename, 
reorder-fields, extract, etc) via sub-commands (a la git).  However, I think 
thats a broader design decision which could be made outside the context of this 
change.  However, if the concern is purely for install-time, we could add 
components to the CMake install to control which of the extra tools are built 
(note that this change doesn't even install the new binary!).


Repository:
  rL LLVM

https://reviews.llvm.org/D23279



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


Re: [PATCH] D23242: [CUDA] Raise an error if a wrong-side call is codegen'ed.

2016-08-08 Thread Artem Belevich via cfe-commits
tra accepted this revision.
tra added a comment.
This revision is now accepted and ready to land.

Few nits, but looks good otherwise.
Should be add few tests for calling device functions from host-side global 
initializers? Perhaps for device->host, too, as there may be unexpected 
interplay with constructor emptiness checks.



Comment at: clang/include/clang/Sema/Sema.h:9162
@@ -9161,1 +9161,3 @@
 
+  /// Check whether we're allowed to call Callee from the current context.
+  ///

\p Callee



Comment at: clang/lib/Sema/SemaCUDA.cpp:493
@@ +492,3 @@
+  if (Pref == Sema::CFP_Never) {
+Diag(Loc, diag::err_ref_bad_target) << IdentifyCUDATarget(Callee) << Callee
+<< IdentifyCUDATarget(Caller);

Perhaps we should add assert(Callee) before we use it.


Comment at: clang/lib/Sema/SemaDeclCXX.cpp:11510-11511
@@ -11509,1 +11509,4 @@
   MarkFunctionReferenced(ConstructLoc, Constructor);
+  if (getLangOpts().CUDA)
+if (!CheckCUDACall(ConstructLoc, Constructor))
+  return ExprError();

Single `if` would do here.


Comment at: clang/lib/Sema/SemaExpr.cpp:5119
@@ -5126,8 +5118,3 @@
 
-/// ActOnCallExpr - Handle a call to Fn with the specified array of arguments.
-/// This provides the location of the left/right parens and a list of comma
-/// locations.
-ExprResult
-Sema::ActOnCallExpr(Scope *S, Expr *Fn, SourceLocation LParenLoc,
-MultiExprArg ArgExprs, SourceLocation RParenLoc,
-Expr *ExecConfig, bool IsExecConfig) {
+ExprResult ActOnCallExprImpl(Sema , Scope *Scope, Expr *Fn,
+ SourceLocation LParenLoc, MultiExprArg ArgExprs,

static?


https://reviews.llvm.org/D23242



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


Re: [PATCH] D19909: [Attr] Add support for the `ms_hook_prologue` attribute.

2016-08-08 Thread Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL278050: [Attr] Add support for the `ms_hook_prologue` 
attribute. (authored by cdavis).

Changed prior to commit:
  https://reviews.llvm.org/D19909?vs=66729=67224#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D19909

Files:
  cfe/trunk/include/clang/Basic/Attr.td
  cfe/trunk/include/clang/Basic/AttrDocs.td
  cfe/trunk/lib/CodeGen/TargetInfo.cpp
  cfe/trunk/lib/Sema/SemaDeclAttr.cpp
  cfe/trunk/test/CodeGen/function-attributes.c
  cfe/trunk/test/Sema/attr-ms-hook-prologue-wrong-arch.c
  cfe/trunk/test/Sema/attr-ms-hook-prologue.c

Index: cfe/trunk/lib/CodeGen/TargetInfo.cpp
===
--- cfe/trunk/lib/CodeGen/TargetInfo.cpp
+++ cfe/trunk/lib/CodeGen/TargetInfo.cpp
@@ -1779,6 +1779,10 @@
   llvm::Function *Fn = cast(GV);
   Fn->setCallingConv(llvm::CallingConv::X86_INTR);
 }
+if (FD->hasAttr()) {
+  llvm::Function *Fn = cast(GV);
+  Fn->addFnAttr("patchable-function", "ms-hotpatch");
+}
   }
 }
 
@@ -2109,6 +2113,10 @@
 llvm::Function *Fn = cast(GV);
 Fn->setCallingConv(llvm::CallingConv::X86_INTR);
   }
+  if (FD->hasAttr()) {
+llvm::Function *Fn = cast(GV);
+Fn->addFnAttr("patchable-function", "ms-hotpatch");
+  }
 }
   }
 };
Index: cfe/trunk/lib/Sema/SemaDeclAttr.cpp
===
--- cfe/trunk/lib/Sema/SemaDeclAttr.cpp
+++ cfe/trunk/lib/Sema/SemaDeclAttr.cpp
@@ -1664,15 +1664,6 @@
 D->addAttr(CA);
 }
 
-static void handleNakedAttr(Sema , Decl *D, const AttributeList ) {
-  if (checkAttrMutualExclusion(S, D, Attr.getRange(),
- Attr.getName()))
-return;
-
-  D->addAttr(::new (S.Context) NakedAttr(Attr.getRange(), S.Context,
- Attr.getAttributeSpellingListIndex()));
-}
-
 static void handleNoReturnAttr(Sema , Decl *D, const AttributeList ) {
   if (hasDeclarator(D)) return;
 
@@ -3673,7 +3664,9 @@
 static void handleAlwaysInlineAttr(Sema , Decl *D,
const AttributeList ) {
   if (checkAttrMutualExclusion(S, D, Attr.getRange(),
-  Attr.getName()))
+  Attr.getName()) ||
+  checkAttrMutualExclusion(S, D, Attr.getRange(),
+   Attr.getName()))
 return;
 
   if (AlwaysInlineAttr *Inline = S.mergeAlwaysInlineAttr(
@@ -5552,7 +5545,8 @@
 handleHotAttr(S, D, Attr);
 break;
   case AttributeList::AT_Naked:
-handleNakedAttr(S, D, Attr);
+handleSimpleAttributeWithExclusions(S, D, Attr);
 break;
   case AttributeList::AT_NoReturn:
 handleNoReturnAttr(S, D, Attr);
@@ -5780,6 +5774,9 @@
 break;
   case AttributeList::AT_LayoutVersion:
 handleLayoutVersion(S, D, Attr);
+  case AttributeList::AT_MSHookPrologue:
+handleSimpleAttributeWithExclusions(S, D, Attr);
 break;
   case AttributeList::AT_MSNoVTable:
 handleSimpleAttribute(S, D, Attr);
Index: cfe/trunk/include/clang/Basic/AttrDocs.td
===
--- cfe/trunk/include/clang/Basic/AttrDocs.td
+++ cfe/trunk/include/clang/Basic/AttrDocs.td
@@ -548,6 +548,22 @@
   }];
 }
 
+def MSHookPrologueDocs : Documentation {
+  let Category = DocCatFunction;
+  let Content = [{
+The ``ms_hook_prologue`` attribute marks a function as "hotpatchable" according
+to conventions used on Windows. Specifically, enough space will be ensured
+in the prologue for a short jump, and an architecturally dependently sized
+patch space will be reserved prior to the entry point. See the documentation
+for the `/HOTPATCH`_ switch on MSDN.
+
+This attribute cannot be used in conjunction with the ``naked``,
+``always_inline``, or ``__forceinline`` attributes.
+
+.. _`/HOTPATCH`: https://msdn.microsoft.com/en-us/library/ms173507.aspx
+  }];
+}
+
 def NoDebugDocs : Documentation {
   let Category = DocCatVariable;
   let Content = [{
Index: cfe/trunk/include/clang/Basic/Attr.td
===
--- cfe/trunk/include/clang/Basic/Attr.td
+++ cfe/trunk/include/clang/Basic/Attr.td
@@ -257,6 +257,7 @@
 def TargetMSP430 : TargetArch<["msp430"]>;
 def TargetX86 : TargetArch<["x86"]>;
 def TargetAnyX86 : TargetArch<["x86", "x86_64"]>;
+def TargetWindowsArches : TargetArch<["x86", "x86_64", "arm", "thumb"]>;
 def TargetWindows : TargetArch<["x86", "x86_64", "arm", "thumb"]> {
   let OSes = ["Win32"];
 }
@@ -2069,6 +2070,12 @@
 
 // Microsoft-related attributes
 
+def MSHookPrologue : InheritableAttr, TargetSpecificAttr {
+  let Spellings = 

r278050 - [Attr] Add support for the `ms_hook_prologue` attribute.

2016-08-08 Thread Charles Davis via cfe-commits
Author: cdavis
Date: Mon Aug  8 16:03:39 2016
New Revision: 278050

URL: http://llvm.org/viewvc/llvm-project?rev=278050=rev
Log:
[Attr] Add support for the `ms_hook_prologue` attribute.

Summary:
Based on a patch by Michael Mueller.

This attribute specifies that a function can be hooked or patched. This
mechanism was originally devised by Microsoft for hotpatching their
binaries (which they're constantly updating to stay ahead of crackers,
script kiddies, and other ne'er-do-wells on the Internet), but it's now
commonly abused by Windows programs that want to hook API functions. It
is for this reason that this attribute was added to GCC--hence the name,
`ms_hook_prologue`.

Depends on D19908.

Reviewers: rnk, aaron.ballman

Subscribers: cfe-commits

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

Added:
cfe/trunk/test/Sema/attr-ms-hook-prologue-wrong-arch.c
cfe/trunk/test/Sema/attr-ms-hook-prologue.c
Modified:
cfe/trunk/include/clang/Basic/Attr.td
cfe/trunk/include/clang/Basic/AttrDocs.td
cfe/trunk/lib/CodeGen/TargetInfo.cpp
cfe/trunk/lib/Sema/SemaDeclAttr.cpp
cfe/trunk/test/CodeGen/function-attributes.c

Modified: cfe/trunk/include/clang/Basic/Attr.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Attr.td?rev=278050=278049=278050=diff
==
--- cfe/trunk/include/clang/Basic/Attr.td (original)
+++ cfe/trunk/include/clang/Basic/Attr.td Mon Aug  8 16:03:39 2016
@@ -257,6 +257,7 @@ def TargetMips : TargetArch<["mips", "mi
 def TargetMSP430 : TargetArch<["msp430"]>;
 def TargetX86 : TargetArch<["x86"]>;
 def TargetAnyX86 : TargetArch<["x86", "x86_64"]>;
+def TargetWindowsArches : TargetArch<["x86", "x86_64", "arm", "thumb"]>;
 def TargetWindows : TargetArch<["x86", "x86_64", "arm", "thumb"]> {
   let OSes = ["Win32"];
 }
@@ -2069,6 +2070,12 @@ def TypeTagForDatatype : InheritableAttr
 
 // Microsoft-related attributes
 
+def MSHookPrologue : InheritableAttr, TargetSpecificAttr {
+  let Spellings = [GCC<"ms_hook_prologue">];
+  let Subjects = SubjectList<[Function]>;
+  let Documentation = [MSHookPrologueDocs];
+}
+
 def MSNoVTable : InheritableAttr, TargetSpecificAttr {
   let Spellings = [Declspec<"novtable">];
   let Subjects = SubjectList<[CXXRecord]>;

Modified: cfe/trunk/include/clang/Basic/AttrDocs.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/AttrDocs.td?rev=278050=278049=278050=diff
==
--- cfe/trunk/include/clang/Basic/AttrDocs.td (original)
+++ cfe/trunk/include/clang/Basic/AttrDocs.td Mon Aug  8 16:03:39 2016
@@ -548,6 +548,22 @@ Query for this feature with ``__has_attr
   }];
 }
 
+def MSHookPrologueDocs : Documentation {
+  let Category = DocCatFunction;
+  let Content = [{
+The ``ms_hook_prologue`` attribute marks a function as "hotpatchable" according
+to conventions used on Windows. Specifically, enough space will be ensured
+in the prologue for a short jump, and an architecturally dependently sized
+patch space will be reserved prior to the entry point. See the documentation
+for the `/HOTPATCH`_ switch on MSDN.
+
+This attribute cannot be used in conjunction with the ``naked``,
+``always_inline``, or ``__forceinline`` attributes.
+
+.. _`/HOTPATCH`: https://msdn.microsoft.com/en-us/library/ms173507.aspx
+  }];
+}
+
 def NoDebugDocs : Documentation {
   let Category = DocCatVariable;
   let Content = [{

Modified: cfe/trunk/lib/CodeGen/TargetInfo.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/TargetInfo.cpp?rev=278050=278049=278050=diff
==
--- cfe/trunk/lib/CodeGen/TargetInfo.cpp (original)
+++ cfe/trunk/lib/CodeGen/TargetInfo.cpp Mon Aug  8 16:03:39 2016
@@ -1779,6 +1779,10 @@ void X86_32TargetCodeGenInfo::setTargetA
   llvm::Function *Fn = cast(GV);
   Fn->setCallingConv(llvm::CallingConv::X86_INTR);
 }
+if (FD->hasAttr()) {
+  llvm::Function *Fn = cast(GV);
+  Fn->addFnAttr("patchable-function", "ms-hotpatch");
+}
   }
 }
 
@@ -2109,6 +2113,10 @@ public:
 llvm::Function *Fn = cast(GV);
 Fn->setCallingConv(llvm::CallingConv::X86_INTR);
   }
+  if (FD->hasAttr()) {
+llvm::Function *Fn = cast(GV);
+Fn->addFnAttr("patchable-function", "ms-hotpatch");
+  }
 }
   }
 };

Modified: cfe/trunk/lib/Sema/SemaDeclAttr.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclAttr.cpp?rev=278050=278049=278050=diff
==
--- cfe/trunk/lib/Sema/SemaDeclAttr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclAttr.cpp Mon Aug  8 16:03:39 2016
@@ -1664,15 +1664,6 @@ static void handleCommonAttr(Sema , De
 D->addAttr(CA);
 }
 
-static void handleNakedAttr(Sema , Decl *D, const AttributeList ) {
-  if 

Re: [PATCH] D23279: clang-reorder-fields

2016-08-08 Thread Eugene Zelenko via cfe-commits
Eugene.Zelenko added a comment.

May be this could be Clang-rename mode?

My concern is that every added tool is ~ 15-20 MB on Linux and there are no 
CMake options to link part of them dynamically.


Repository:
  rL LLVM

https://reviews.llvm.org/D23279



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


Re: [PATCH] D23244: [Driver] Enable CFI for WebAssembly

2016-08-08 Thread Dan Gohman via cfe-commits
sunfish accepted this revision.
sunfish added a comment.
This revision is now accepted and ready to land.

lgtm.


https://reviews.llvm.org/D23244



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


Re: [PATCH] D23279: clang-reorder-fields

2016-08-08 Thread Alexander Shaposhnikov via cfe-commits
alexshap added a comment.

Thank you for the feedback. I was keeping in mind some other use-cases as well 
- someone might want to change the order of fields even if the padding is not 
affected.


Repository:
  rL LLVM

https://reviews.llvm.org/D23279



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


Re: [PATCH] D23279: clang-reorder-fields

2016-08-08 Thread Eugene Zelenko via cfe-commits
Eugene.Zelenko added a subscriber: Eugene.Zelenko.
Eugene.Zelenko added a comment.

Do we really need standalone tool for this purpose? If I'm not mistaken, Static 
Analyzer already has clang-analyzer-optin.performance.Padding check, which is 
also available through Clang-tidy.


https://reviews.llvm.org/D23279



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


Re: r276900 - [Sema] Teach getCurrentThisType to reconize lambda in in-class initializer

2016-08-08 Thread Hans Wennborg via cfe-commits
Richard: ping?

On Wed, Jul 27, 2016 at 4:46 PM, Hans Wennborg  wrote:
> Should this be merged to 3.9?
>
> Thanks,
> Hans
>
> On Wed, Jul 27, 2016 at 11:25 AM, Erik Pilkington via cfe-commits
>  wrote:
>> Author: epilk
>> Date: Wed Jul 27 13:25:10 2016
>> New Revision: 276900
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=276900=rev
>> Log:
>> [Sema] Teach getCurrentThisType to reconize lambda in in-class initializer
>>
>> Fixes PR27994, a crash on valid.
>>
>> Differential revision: https://reviews.llvm.org/D21145
>>
>> Modified:
>> cfe/trunk/lib/Sema/SemaExprCXX.cpp
>> cfe/trunk/test/SemaCXX/lambda-expressions.cpp
>>
>> Modified: cfe/trunk/lib/Sema/SemaExprCXX.cpp
>> URL: 
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExprCXX.cpp?rev=276900=276899=276900=diff
>> ==
>> --- cfe/trunk/lib/Sema/SemaExprCXX.cpp (original)
>> +++ cfe/trunk/lib/Sema/SemaExprCXX.cpp Wed Jul 27 13:25:10 2016
>> @@ -961,32 +961,26 @@ static QualType adjustCVQualifiersForCXX
>>  QualType Sema::getCurrentThisType() {
>>DeclContext *DC = getFunctionLevelDeclContext();
>>QualType ThisTy = CXXThisTypeOverride;
>> +
>>if (CXXMethodDecl *method = dyn_cast(DC)) {
>>  if (method && method->isInstance())
>>ThisTy = method->getThisType(Context);
>>}
>> -  if (ThisTy.isNull()) {
>> -if (isGenericLambdaCallOperatorSpecialization(CurContext) &&
>> -CurContext->getParent()->getParent()->isRecord()) {
>> -  // This is a generic lambda call operator that is being instantiated
>> -  // within a default initializer - so use the enclosing class as 
>> 'this'.
>> -  // There is no enclosing member function to retrieve the 'this' 
>> pointer
>> -  // from.
>> -
>> -  // FIXME: This looks wrong. If we're in a lambda within a lambda 
>> within a
>> -  // default member initializer, we need to recurse up more parents to 
>> find
>> -  // the right context. Looks like we should be walking up to the 
>> parent of
>> -  // the closure type, checking whether that is itself a lambda, and if 
>> so,
>> -  // recursing, until we reach a class or a function that isn't a lambda
>> -  // call operator. And we should accumulate the constness of *this on 
>> the
>> -  // way.
>> -
>> -  QualType ClassTy = Context.getTypeDeclType(
>> -  cast(CurContext->getParent()->getParent()));
>> -  // There are no cv-qualifiers for 'this' within default initializers,
>> -  // per [expr.prim.general]p4.
>> -  ThisTy = Context.getPointerType(ClassTy);
>> -}
>> +
>> +  if (ThisTy.isNull() && isLambdaCallOperator(CurContext) &&
>> +  !ActiveTemplateInstantiations.empty()) {
>> +
>> +assert(isa(DC) &&
>> +   "Trying to get 'this' type from static method?");
>> +
>> +// This is a lambda call operator that is being instantiated as a 
>> default
>> +// initializer. DC must point to the enclosing class type, so we can 
>> recover
>> +// the 'this' type from it.
>> +
>> +QualType ClassTy = Context.getTypeDeclType(cast(DC));
>> +// There are no cv-qualifiers for 'this' within default initializers,
>> +// per [expr.prim.general]p4.
>> +ThisTy = Context.getPointerType(ClassTy);
>>}
>>
>>// If we are within a lambda's call operator, the cv-qualifiers of 'this'
>>
>> Modified: cfe/trunk/test/SemaCXX/lambda-expressions.cpp
>> URL: 
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/lambda-expressions.cpp?rev=276900=276899=276900=diff
>> ==
>> --- cfe/trunk/test/SemaCXX/lambda-expressions.cpp (original)
>> +++ cfe/trunk/test/SemaCXX/lambda-expressions.cpp Wed Jul 27 13:25:10 2016
>> @@ -1,5 +1,4 @@
>> -// RUN: %clang_cc1 -std=c++11 -Wno-unused-value -fsyntax-only -verify 
>> -fblocks %s
>> -// RUN: %clang_cc1 -std=c++1y -Wno-unused-value -fsyntax-only -verify 
>> -fblocks %s
>> +// RUN: %clang_cc1 -std=c++14 -Wno-unused-value -fsyntax-only -verify 
>> -fblocks %s
>>
>>  namespace std { class type_info; };
>>
>> @@ -499,3 +498,30 @@ void foo() {
>>};
>>  }
>>  }
>> +
>> +namespace PR27994 {
>> +struct A { template  A(T); };
>> +
>> +template 
>> +struct B {
>> +  int x;
>> +  A a = [&] { int y = x; };
>> +  A b = [&] { [&] { [&] { int y = x; }; }; };
>> +  A d = [&](auto param) { int y = x; };
>> +  A e = [&](auto param) { [&] { [&](auto param2) { int y = x; }; }; };
>> +};
>> +
>> +B b;
>> +
>> +template  struct C {
>> +  struct D {
>> +int x;
>> +A f = [&] { int y = x; };
>> +  };
>> +};
>> +
>> +int func() {
>> +  C a;
>> +  decltype(a)::D b;
>> +}
>> +}
>>
>>
>> ___
>> cfe-commits mailing list
>> cfe-commits@lists.llvm.org
>> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
___
cfe-commits 

Re: [PATCH] D23236: When ARC is enabled, no warning will be generated when a method1. Returns 'nil' in a method that is attributed to return a 'nonnull'2. The return-statement is a ConditionalOperator

2016-08-08 Thread Akira Hatanaka via cfe-commits
ahatanak added a subscriber: cfe-commits.
ahatanak added a comment.

+cfe-commits

If this patch is applied, does clang issue a warning if a method marked 
"nonnull" returns a null value? I see a warning is issued for conditional 
expressions in the test case you've added, but I don't see a test case for a 
function returning just nil or 0.

I was wondering whether the change made in this patch contradicts what's stated 
in r240146's commit log:

"Note that we don't warn about nil returns from Objective-C methods,

  because it's common for Objective-C methods to mimic the nil-swallowing
  behavior of the receiver by checking ostensibly non-null parameters
  and returning nil from otherwise non-null methods in that
  case."


https://reviews.llvm.org/D23236



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


Re: [libcxx] r278032 - CMakeLists.txt cleanups: synchronize version with rest of LLVM, consistent spacing.

2016-08-08 Thread Hans Wennborg via cfe-commits
I didn't merge this one to 3.9 because the PACKAGE_VERSION seems to
have always been trunk-svn, and it's at least not as misleading as
having the wrong number.

I wonder if PACKAGE_VERSION is actually important for anything in
libcxx, libcxxabi and libunwind? At least for libcxx, the important
version is _LIBCPP_VERSION in include/__config.

Thanks,
Hans

On Mon, Aug 8, 2016 at 11:01 AM, Eugene Zelenko via cfe-commits
 wrote:
> Author: eugenezelenko
> Date: Mon Aug  8 13:01:50 2016
> New Revision: 278032
>
> URL: http://llvm.org/viewvc/llvm-project?rev=278032=rev
> Log:
> CMakeLists.txt cleanups: synchronize version with rest of LLVM, consistent 
> spacing.
>
> Differential revision: https://reviews.llvm.org/D23091
>
> Modified:
> libcxx/trunk/CMakeLists.txt
>
> Modified: libcxx/trunk/CMakeLists.txt
> URL: 
> http://llvm.org/viewvc/llvm-project/libcxx/trunk/CMakeLists.txt?rev=278032=278031=278032=diff
> ==
> --- libcxx/trunk/CMakeLists.txt (original)
> +++ libcxx/trunk/CMakeLists.txt Mon Aug  8 13:01:50 2016
> @@ -26,10 +26,10 @@ if (LIBCXX_BUILT_STANDALONE)
>project(libcxx CXX C)
>
>set(PACKAGE_NAME libcxx)
> -  set(PACKAGE_VERSION trunk-svn)
> +  set(PACKAGE_VERSION 4.0.0svn)
>set(PACKAGE_STRING "${PACKAGE_NAME} ${PACKAGE_VERSION}")
>set(PACKAGE_BUGREPORT "llvm-b...@lists.llvm.org")
> -endif ()
> +endif()
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D23279: clang-reorder-fields

2016-08-08 Thread Alexander Shaposhnikov via cfe-commits
alexshap created this revision.
alexshap added reviewers: klimek, compnerd.
alexshap added a subscriber: cfe-commits.
alexshap changed the visibility of this Differential Revision from "Public (No 
Login Required)" to "All Users".

This diff adds v0 of clang-reorder-fields tool to clang/tools/extra.
The main idea behind this tool is to simplify and make less error-prone 
refactoring of large codebases when
someone needs to change the order fields of a struct/class (for example to 
remove excess padding).

https://reviews.llvm.org/D23279

Files:
  CMakeLists.txt
  clang-reorder-fields/CMakeLists.txt
  clang-reorder-fields/ReorderFieldsAction.cpp
  clang-reorder-fields/ReorderFieldsAction.h
  clang-reorder-fields/tool/CMakeLists.txt
  clang-reorder-fields/tool/ClangReorderFields.cpp
  test/CMakeLists.txt
  test/clang-reorder-fields/CStructAmbiguousName.cpp
  test/clang-reorder-fields/CStructFieldPos.cpp
  test/clang-reorder-fields/CStructFieldsOrder.cpp

Index: test/clang-reorder-fields/CStructFieldsOrder.cpp
===
--- test/clang-reorder-fields/CStructFieldsOrder.cpp
+++ test/clang-reorder-fields/CStructFieldsOrder.cpp
@@ -0,0 +1,18 @@
+// RUN: cat %s > %t.cpp
+// RUN: clang-reorder-fields -record-name ::bar::Foo -fields-order z,w,y,x %t.cpp -i --
+// RUN: sed 's,//.*,,' %t.cpp | FileCheck %s
+
+namespace bar {
+struct Foo {
+  const int* x; // CHECK: double z;
+  int y;// CHECK: int w;
+  double z; // CHECK: int y;
+  int w;// CHECK: const int* x;
+};
+} // end namespace bar
+
+int main() {
+  const int x = 13;
+  bar::Foo foo = { , 17, 1.29, 0 }; // CHECK: bar::Foo foo = { 1.29, 0, 17,  };
+  return 0;
+}
Index: test/clang-reorder-fields/CStructFieldPos.cpp
===
--- test/clang-reorder-fields/CStructFieldPos.cpp
+++ test/clang-reorder-fields/CStructFieldPos.cpp
@@ -0,0 +1,16 @@
+// RUN: cat %s > %t.cpp
+// RUN: clang-reorder-fields -record-name ::Foo -field-pos z:0 %t.cpp -i --
+// RUN: sed 's,//.*,,' %t.cpp | FileCheck %s
+
+struct Foo {
+  const int* x; // CHECK: double z;
+  int y;// CHECK: const int* x;
+  double z; // CHECK: int y;
+  int w;// CHECK: int w;
+};
+
+int main() {
+  const int x = 13;
+  Foo foo = { , 17, 1.29, 0 }; // CHECK: Foo foo = { 1.29, , 17, 0 };
+  return 0;
+}
Index: test/clang-reorder-fields/CStructAmbiguousName.cpp
===
--- test/clang-reorder-fields/CStructAmbiguousName.cpp
+++ test/clang-reorder-fields/CStructAmbiguousName.cpp
@@ -0,0 +1,20 @@
+// RUN: cat %s > %t.cpp
+// RUN: clang-reorder-fields -record-name Foo -fields-order y,x %t.cpp -i --
+// RUN: sed 's,//.*,,' %t.cpp | FileCheck %s
+
+struct Foo {
+  int x;// CHECK: int x;
+  double y; // CHECK: double y;
+};
+
+namespace bar {
+struct Foo {
+  int x;// CHECK: int x;
+  double y; // CHECK: double y;
+};
+} // end namespace bar
+
+int main() {
+  Foo foo = { 1, 1.7 }; // CHECK: Foo foo = { 1, 1.7 };
+  return 0;
+}
Index: test/CMakeLists.txt
===
--- test/CMakeLists.txt
+++ test/CMakeLists.txt
@@ -45,6 +45,7 @@
   clang-include-fixer
   clang-query
   clang-rename
+  clang-reorder-fields
   clang-tidy
   find-all-symbols
   modularize
Index: clang-reorder-fields/tool/ClangReorderFields.cpp
===
--- clang-reorder-fields/tool/ClangReorderFields.cpp
+++ clang-reorder-fields/tool/ClangReorderFields.cpp
@@ -0,0 +1,135 @@
+//===-- tools/extra/clang-reorder-fields/tool/ClangReorderFields.cpp -*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+///
+/// \file
+/// This file contains the implementation of clang-reorder-fields tool
+///
+//===--===//
+
+#include "../ReorderFieldsAction.h"
+#include "clang/Basic/Diagnostic.h"
+#include "clang/Basic/DiagnosticOptions.h"
+#include "clang/Basic/FileManager.h"
+#include "clang/Basic/LangOptions.h"
+#include "clang/Basic/SourceManager.h"
+#include "clang/Frontend/TextDiagnosticPrinter.h"
+#include "clang/Rewrite/Core/Rewriter.h"
+#include "clang/Tooling/CommonOptionsParser.h"
+#include "clang/Tooling/Refactoring.h"
+#include "clang/Tooling/Tooling.h"
+#include "llvm/ADT/IntrusiveRefCntPtr.h"
+#include "llvm/Support/CommandLine.h"
+#include "llvm/Support/FileSystem.h"
+#include 
+#include 
+#include 
+#include 
+
+using namespace llvm;
+using namespace clang;
+
+cl::OptionCategory ClangReorderFieldsCategory("clang-reorder-fields options");
+
+// FIXME: error-handling
+struct FieldsOrderParser : cl::parser> {

Re: [PATCH] D22946: [CUDA] Regression test to make sure C++ include path are forwarded to host and device frontends.

2016-08-08 Thread Artem Belevich via cfe-commits
tra added a comment.

cuda-detect.cu may be a better place for this test.



Comment at: test/Driver/cuda-simple.cu:27
@@ -16,1 +26,3 @@
+// CHECK-CXXINCLUDE: clang{{.*}} "-cc1" "-triple" "x86_64--linux-gnu" 
{{.*}}"-internal-isystem" "{{.+}}/include/c++/4.8"
+// CHECK-CXXINCLUDE: ld" {{.*}}"-m" "elf_x86_64"
 

Linker match pattern will cause problems on windows. We normally use 
`ld{{.*}}"` .

Linker options are irrelevant here, IMO, as this line is only used as a marker 
for the end of the list of commands produced by compiler.


https://reviews.llvm.org/D22946



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


Re: [libcxxabi] r278030 - CMakeLists.txt cleanups: synchronize version with rest of LLVM, consistent spacing.

2016-08-08 Thread Hans Wennborg via cfe-commits
Merged to 3.9 in r278044 with the version number adjusted.

On Mon, Aug 8, 2016 at 10:59 AM, Eugene Zelenko via cfe-commits
 wrote:
> Author: eugenezelenko
> Date: Mon Aug  8 12:59:02 2016
> New Revision: 278030
>
> URL: http://llvm.org/viewvc/llvm-project?rev=278030=rev
> Log:
> CMakeLists.txt cleanups: synchronize version with rest of LLVM, consistent 
> spacing.
>
> Differential revision: https://reviews.llvm.org/D23092
>
> Modified:
> libcxxabi/trunk/CMakeLists.txt
>
> Modified: libcxxabi/trunk/CMakeLists.txt
> URL: 
> http://llvm.org/viewvc/llvm-project/libcxxabi/trunk/CMakeLists.txt?rev=278030=278029=278030=diff
> ==
> --- libcxxabi/trunk/CMakeLists.txt (original)
> +++ libcxxabi/trunk/CMakeLists.txt Mon Aug  8 12:59:02 2016
> @@ -64,7 +64,7 @@ if (CMAKE_SOURCE_DIR STREQUAL CMAKE_CURR
>endif()
>
>set(PACKAGE_NAME libcxxabi)
> -  set(PACKAGE_VERSION 3.7.0svn)
> +  set(PACKAGE_VERSION 4.0.0svn)
>set(PACKAGE_STRING "${PACKAGE_NAME} ${PACKAGE_VERSION}")
>set(PACKAGE_BUGREPORT "llvm-b...@lists.llvm.org")
>
> @@ -189,8 +189,7 @@ set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${LIB
>  if (NOT LIBCXXABI_LIBCXX_LIBRARY_PATH)
>set(LIBCXXABI_LIBCXX_LIBRARY_PATH "${LIBCXXABI_LIBRARY_DIR}" CACHE PATH
>"The path to libc++ library.")
> -endif ()
> -
> +endif()
>
>  # Check that we can build with 32 bits if requested.
>  if (CMAKE_SIZEOF_VOID_P EQUAL 8 AND NOT WIN32)
> @@ -246,7 +245,7 @@ endif()
>
>  if (LIBCXXABI_USE_COMPILER_RT)
>list(APPEND LIBCXXABI_LINK_FLAGS "-rtlib=compiler-rt")
> -endif ()
> +endif()
>
>  append_if(LIBCXXABI_COMPILE_FLAGS LIBCXXABI_HAS_WERROR_FLAG 
> -Werror=return-type)
>
> @@ -383,7 +382,7 @@ if (LIBCXXABI_USE_LLVM_UNWINDER OR LLVM_
>
>include_directories("${LIBCXXABI_LIBUNWIND_INCLUDES_INTERNAL}")
>include_directories("${LIBCXXABI_LIBUNWIND_SOURCES}")
> -endif ()
> +endif()
>
>  # Add source code. This also contains all of the logic for deciding linker 
> flags
>  # soname, etc...
>
>
> ___
> 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


[libcxxabi] r278044 - Merging r278030 with version number adjusted:

2016-08-08 Thread Hans Wennborg via cfe-commits
Author: hans
Date: Mon Aug  8 15:06:27 2016
New Revision: 278044

URL: http://llvm.org/viewvc/llvm-project?rev=278044=rev
Log:
Merging r278030 with version number adjusted:

r278030 | eugenezelenko | 2016-08-08 10:59:02 -0700 (Mon, 08 Aug 2016) | 4 lines

CMakeLists.txt cleanups: synchronize version with rest of LLVM, consistent 
spacing.

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



Modified:
libcxxabi/branches/release_39/   (props changed)
libcxxabi/branches/release_39/CMakeLists.txt

Propchange: libcxxabi/branches/release_39/
--
svn:mergeinfo = /libcxxabi/trunk:278030

Modified: libcxxabi/branches/release_39/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/libcxxabi/branches/release_39/CMakeLists.txt?rev=278044=278043=278044=diff
==
--- libcxxabi/branches/release_39/CMakeLists.txt (original)
+++ libcxxabi/branches/release_39/CMakeLists.txt Mon Aug  8 15:06:27 2016
@@ -64,7 +64,7 @@ if (CMAKE_SOURCE_DIR STREQUAL CMAKE_CURR
   endif()
 
   set(PACKAGE_NAME libcxxabi)
-  set(PACKAGE_VERSION 3.7.0svn)
+  set(PACKAGE_VERSION 3.9.0)
   set(PACKAGE_STRING "${PACKAGE_NAME} ${PACKAGE_VERSION}")
   set(PACKAGE_BUGREPORT "llvm-b...@lists.llvm.org")
 
@@ -189,8 +189,7 @@ set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${LIB
 if (NOT LIBCXXABI_LIBCXX_LIBRARY_PATH)
   set(LIBCXXABI_LIBCXX_LIBRARY_PATH "${LIBCXXABI_LIBRARY_DIR}" CACHE PATH
   "The path to libc++ library.")
-endif ()
-
+endif()
 
 # Check that we can build with 32 bits if requested.
 if (CMAKE_SIZEOF_VOID_P EQUAL 8 AND NOT WIN32)
@@ -246,7 +245,7 @@ endif()
 
 if (LIBCXXABI_USE_COMPILER_RT)
   list(APPEND LIBCXXABI_LINK_FLAGS "-rtlib=compiler-rt")
-endif ()
+endif()
 
 append_if(LIBCXXABI_COMPILE_FLAGS LIBCXXABI_HAS_WERROR_FLAG 
-Werror=return-type)
 
@@ -383,7 +382,7 @@ if (LIBCXXABI_USE_LLVM_UNWINDER OR LLVM_
 
   include_directories("${LIBCXXABI_LIBUNWIND_INCLUDES_INTERNAL}")
   include_directories("${LIBCXXABI_LIBUNWIND_SOURCES}")
-endif ()
+endif()
 
 # Add source code. This also contains all of the logic for deciding linker 
flags
 # soname, etc...


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


Re: [libunwind] r278029 - CMakeLists.txt cleanups: synchronize version and CMake minimum required version with rest of LLVM, consistent spacing.

2016-08-08 Thread Hans Wennborg via cfe-commits
Merged to 3.9 in r278043 with the version number adjusted.

On Mon, Aug 8, 2016 at 10:56 AM, Eugene Zelenko via cfe-commits
 wrote:
> Author: eugenezelenko
> Date: Mon Aug  8 12:56:28 2016
> New Revision: 278029
>
> URL: http://llvm.org/viewvc/llvm-project?rev=278029=rev
> Log:
> CMakeLists.txt cleanups: synchronize version and CMake minimum required 
> version with rest of LLVM, consistent spacing.
>
> Differential revision: https://reviews.llvm.org/D23094
>
> Modified:
> libunwind/trunk/CMakeLists.txt
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[libunwind] r278043 - Merging r278029 with version number adjusted:

2016-08-08 Thread Hans Wennborg via cfe-commits
Author: hans
Date: Mon Aug  8 15:04:18 2016
New Revision: 278043

URL: http://llvm.org/viewvc/llvm-project?rev=278043=rev
Log:
Merging r278029 with version number adjusted:

r278029 | eugenezelenko | 2016-08-08 10:56:28 -0700 (Mon, 08 Aug 2016) | 4 lines

CMakeLists.txt cleanups: synchronize version and CMake minimum required version 
with rest of LLVM, consistent spacing.

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



Modified:
libunwind/branches/release_39/   (props changed)
libunwind/branches/release_39/CMakeLists.txt

Propchange: libunwind/branches/release_39/
--
--- svn:mergeinfo (original)
+++ svn:mergeinfo Mon Aug  8 15:04:18 2016
@@ -1 +1 @@
-/libunwind/trunk:276128,277868
+/libunwind/trunk:276128,277868,278029

Modified: libunwind/branches/release_39/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/libunwind/branches/release_39/CMakeLists.txt?rev=278043=278042=278043=diff
==
--- libunwind/branches/release_39/CMakeLists.txt (original)
+++ libunwind/branches/release_39/CMakeLists.txt Mon Aug  8 15:04:18 2016
@@ -2,7 +2,7 @@
 # Setup Project
 
#===
 
-cmake_minimum_required(VERSION 2.8.8)
+cmake_minimum_required(VERSION 3.4.3)
 
 if (POLICY CMP0042)
   cmake_policy(SET CMP0042 NEW) # Set MACOSX_RPATH=YES by default
@@ -28,11 +28,11 @@ if (CMAKE_SOURCE_DIR STREQUAL CMAKE_CURR
 if (NOT HAD_ERROR)
   string(REGEX REPLACE "[ \t]*[\r\n]+[ \t]*" ";"
  CONFIG_OUTPUT ${CONFIG_OUTPUT})
-else ()
+else()
   string(REPLACE ";" " " CONFIG_COMMAND_STR "${CONFIG_COMMAND}")
   message(STATUS "${CONFIG_COMMAND_STR}")
   message(FATAL_ERROR "llvm-config failed with status ${HAD_ERROR}")
-endif ()
+endif()
 
 list(GET CONFIG_OUTPUT 0 INCLUDE_DIR)
 list(GET CONFIG_OUTPUT 1 LLVM_OBJ_ROOT)
@@ -43,32 +43,32 @@ if (CMAKE_SOURCE_DIR STREQUAL CMAKE_CURR
 set(LLVM_MAIN_SRC_DIR ${MAIN_SRC_DIR} CACHE PATH "Path to LLVM source 
tree")
 set(LLVM_CMAKE_PATH 
"${LLVM_BINARY_DIR}/lib${LLVM_LIBDIR_SUFFIX}/cmake/llvm")
 set(LLVM_LIT_PATH "${LLVM_PATH}/utils/lit/lit.py")
-  else ()
+  else()
 message(FATAL_ERROR "llvm-config not found and LLVM_MAIN_SRC_DIR not 
defined. "
 "Reconfigure with -DLLVM_CONFIG=path/to/llvm-config "
 "or -DLLVM_PATH=path/to/llvm-source-root.")
-  endif ()
+  endif()
 
   if (EXISTS ${LLVM_CMAKE_PATH})
 list(APPEND CMAKE_MODULE_PATH "${LLVM_CMAKE_PATH}")
 include("${LLVM_CMAKE_PATH}/AddLLVM.cmake")
 include("${LLVM_CMAKE_PATH}/HandleLLVMOptions.cmake")
-  else ()
+  else()
 message(FATAL_ERROR "Not found: ${LLVM_CMAKE_PATH}")
-  endif ()
+  endif()
 
   set(PACKAGE_NAME libunwind)
-  set(PACKAGE_VERSION 3.8.0svn)
+  set(PACKAGE_VERSION 3.9.0)
   set(PACKAGE_STRING "${PACKAGE_NAME} ${PACKAGE_VERSION}")
   set(PACKAGE_BUGREPORT "llvm-b...@lists.llvm.org")
 
   if (EXISTS ${LLVM_MAIN_SRC_DIR}/utils/lit/lit.py)
 set(LLVM_LIT ${LLVM_MAIN_SRC_DIR}/utils/lit/lit.py)
-  else ()
+  else()
 # Seek installed Lit.
 find_program(LLVM_LIT "lit.py" ${LLVM_MAIN_SRC_DIR}/utils/lit
  DOC "Path to lit.py")
-  endif ()
+  endif()
 
   if (LLVM_LIT)
 # Define the default arguments to use with 'lit', and an option for the 
user
@@ -76,16 +76,16 @@ if (CMAKE_SOURCE_DIR STREQUAL CMAKE_CURR
 set(LIT_ARGS_DEFAULT "-sv")
 if (MSVC OR XCODE)
   set(LIT_ARGS_DEFAULT "${LIT_ARGS_DEFAULT} --no-progress-bar")
-endif ()
+endif()
 set(LLVM_LIT_ARGS "${LIT_ARGS_DEFAULT}" CACHE STRING "Default options for 
lit")
 
 # On Win32 hosts, provide an option to specify the path to the GnuWin32 
tools.
 if (WIN32 AND NOT CYGWIN)
   set(LLVM_LIT_TOOLS_DIR "" CACHE PATH "Path to GnuWin32 tools")
-endif ()
-  else ()
+endif()
+  else()
 set(LLVM_INCLUDE_TESTS OFF)
-  endif ()
+  endif()
 
   set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY 
${CMAKE_BINARY_DIR}/lib${LLVM_LIBDIR_SUFFIX})
   set(CMAKE_LIBRARY_OUTPUT_DIRECTORY 
${CMAKE_BINARY_DIR}/lib${LLVM_LIBDIR_SUFFIX})
@@ -111,7 +111,6 @@ set(LIBUNWIND_TARGET_TRIPLE "" CACHE STR
 set(LIBUNWIND_GCC_TOOLCHAIN "" CACHE PATH "GCC toolchain for cross compiling.")
 set(LIBUNWIND_SYSROOT "" CACHE PATH "Sysroot for cross compiling.")
 
-
 # Check that we can build with 32 bits if requested.
 if (CMAKE_SIZEOF_VOID_P EQUAL 8 AND NOT WIN32)
   if (LIBUNWIND_BUILD_32_BITS AND NOT LLVM_BUILD_32_BITS) # Don't duplicate 
the output from LLVM
@@ -220,23 +219,23 @@ if (LIBUNWIND_ENABLE_ASSERTIONS)
   # MSVC doesn't like _DEBUG on release builds. See PR 4379.
   if (NOT MSVC)
 list(APPEND LIBUNWIND_COMPILE_FLAGS -D_DEBUG)
-  endif 

Re: [PATCH] D22946: [CUDA] Regression test to make sure C++ include path are forwarded to host and device frontends.

2016-08-08 Thread Samuel Antao via cfe-commits
sfantao added a comment.

Friendly ping.

Thanks!


https://reviews.llvm.org/D22946



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


Re: [PATCH] D23167: emit_DW_AT_noreturn flag

2016-08-08 Thread Adrian Prantl via cfe-commits
aprantl added a comment.

Thanks, now all that's missing is an LLVM IR round-trip test. Adding the new 
flag to test/Assembler/disubprogram would work.



Comment at: test/DebugInfo/noreturn_c11.ll:9
@@ +8,3 @@
+
+; CHECK:  DW_AT_noreturn
+

Maybe check for just a bit more context (the DW_TAG_subprogram + DW_AT_name 
should be fine)?


Comment at: test/DebugInfo/noreturn_c11.ll:29
@@ +28,3 @@
+
+attributes #0 = { noreturn nounwind uwtable "disable-tail-calls"="false" 
"less-precise-fpmad"="false" "no-frame-pointer-elim"="true" 
"no-frame-pointer-elim-non-leaf" "no-infs-fp-math"="false" 
"no-jump-tables"="false" "no-nans-fp-math"="false" 
"no-signed-zeros-fp-math"="false" "stack-protector-buffer-size"="8" 
"target-cpu"="x86-64" "target-features"="+fxsr,+mmx,+sse,+sse2,+x87" 
"unsafe-fp-math"="false" "use-soft-float"="false" }
+attributes #1 = { noreturn nounwind "disable-tail-calls"="false" 
"less-precise-fpmad"="false" "no-frame-pointer-elim"="true" 
"no-frame-pointer-elim-non-leaf" "no-infs-fp-math"="false" 
"no-nans-fp-math"="false" "no-signed-zeros-fp-math"="false" 
"stack-protector-buffer-size"="8" "target-cpu"="x86-64" 
"target-features"="+fxsr,+mmx,+sse,+sse2,+x87" "unsafe-fp-math"="false" 
"use-soft-float"="false" }

We typically strip out all unnecessary attributes to not distract from the 
testcase. A good heuristic is that you can usually get rid of everything in 
quotes.


Comment at: test/DebugInfo/noreturn_cpp11.ll:9
@@ +8,3 @@
+
+; CHECK:  DW_AT_noreturn
+

More context.


Comment at: test/DebugInfo/noreturn_cpp11.ll:36
@@ +35,3 @@
+
+attributes #0 = { noreturn uwtable "disable-tail-calls"="false" 
"less-precise-fpmad"="false" "no-frame-pointer-elim"="true" 
"no-frame-pointer-elim-non-leaf" "no-infs-fp-math"="false" 
"no-jump-tables"="false" "no-nans-fp-math"="false" 
"no-signed-zeros-fp-math"="false" "stack-protector-buffer-size"="8" 
"target-cpu"="x86-64" "target-features"="+fxsr,+mmx,+sse,+sse2,+x87" 
"unsafe-fp-math"="false" "use-soft-float"="false" }
+attributes #1 = { nounwind }

Strip attributes.


Comment at: test/DebugInfo/noreturn_objc.ll:10
@@ +9,3 @@
+; }
+
+; CHECK:  DW_AT_noreturn

more context


Comment at: test/DebugInfo/noreturn_objc.ll:31
@@ +30,3 @@
+
+attributes #0 = { noreturn nounwind uwtable "disable-tail-calls"="false" 
"less-precise-fpmad"="false" "no-frame-pointer-elim"="true" 
"no-frame-pointer-elim-non-leaf" "no-infs-fp-math"="false" 
"no-jump-tables"="false" "no-nans-fp-math"="false" 
"no-signed-zeros-fp-math"="false" "stack-protector-buffer-size"="8" 
"target-cpu"="x86-64" "target-features"="+fxsr,+mmx,+sse,+sse2,+x87" 
"unsafe-fp-math"="false" "use-soft-float"="false" }
+attributes #1 = { noreturn nounwind "disable-tail-calls"="false" 
"less-precise-fpmad"="false" "no-frame-pointer-elim"="true" 
"no-frame-pointer-elim-non-leaf" "no-infs-fp-math"="false" 
"no-nans-fp-math"="false" "no-signed-zeros-fp-math"="false" 
"stack-protector-buffer-size"="8" "target-cpu"="x86-64" 
"target-features"="+fxsr,+mmx,+sse,+sse2,+x87" "unsafe-fp-math"="false" 
"use-soft-float"="false" }

strip attributes


https://reviews.llvm.org/D23167



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


Re: [PATCH] D23198: clang-rename rename-all: support reading old/newname pairs from a YAML file

2016-08-08 Thread Miklos Vajna via cfe-commits
vmiklos added a comment.

> .cpp.rename-at.yaml?


I just discovered that lit provides %S that allows getting rid of the confusing
.cpp.yaml, I'm using that now.

> Ah, and yes, it's better to move *.yaml to extra/test/clang-rename/Inputs


Done.


https://reviews.llvm.org/D23198



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


Re: [PATCH] D23198: clang-rename rename-all: support reading old/newname pairs from a YAML file

2016-08-08 Thread Miklos Vajna via cfe-commits
vmiklos updated this revision to Diff 67215.

https://reviews.llvm.org/D23198

Files:
  clang-rename/tool/ClangRename.cpp
  docs/clang-rename.rst
  test/clang-rename/ClassTestMultiByNameYAML.cpp
  test/clang-rename/Inputs/ClassTestMultiByNameYAMLRenameAll.yaml
  test/clang-rename/Inputs/ClassTestMultiByNameYAMLRenameAt.yaml

Index: test/clang-rename/Inputs/ClassTestMultiByNameYAMLRenameAt.yaml
===
--- /dev/null
+++ test/clang-rename/Inputs/ClassTestMultiByNameYAMLRenameAt.yaml
@@ -0,0 +1,6 @@
+---
+- Offset: 6
+  NewName:Bar1
+- Offset: 44
+  NewName:Bar2
+...
Index: test/clang-rename/Inputs/ClassTestMultiByNameYAMLRenameAll.yaml
===
--- /dev/null
+++ test/clang-rename/Inputs/ClassTestMultiByNameYAMLRenameAll.yaml
@@ -0,0 +1,6 @@
+---
+- OldName:Foo1
+  NewName:Bar1
+- OldName:Foo2
+  NewName:Bar2
+...
Index: test/clang-rename/ClassTestMultiByNameYAML.cpp
===
--- /dev/null
+++ test/clang-rename/ClassTestMultiByNameYAML.cpp
@@ -0,0 +1,7 @@
+class Foo1 { // CHECK: class Bar1
+};
+
+class Foo2 { // CHECK: class Bar2
+};
+// RUN: clang-rename rename-all -input %S/Inputs/ClassTestMultiByNameYAMLRenameAll.yaml %s -- | sed 's,//.*,,' | FileCheck %s
+// RUN: clang-rename rename-all -input %S/Inputs/ClassTestMultiByNameYAMLRenameAt.yaml %s -- | sed 's,//.*,,' | FileCheck %s
Index: docs/clang-rename.rst
===
--- docs/clang-rename.rst
+++ docs/clang-rename.rst
@@ -42,23 +42,52 @@
   $ grep -FUbo 'foo' file.cpp
 
 
+The tool currently supports renaming actions inside a single Translation Unit
+only. It is planned to extend the tool's functionality to support multi-TU
+renaming actions in the future.
+
+:program:`clang-rename` also aims to be easily integrated into popular text
+editors, such as Vim and Emacs, and improve the workflow of users.
+
+Although a command line interface exists, it is highly recommended to use the
+text editor interface instead for better experience.
+
 You can also identify one or more symbols to be renamed by giving the fully qualified
 name:
 
 .. code-block:: console
 
   $ clang-rename rename-all -old-name=foo -new-name=bar test.cpp
 
 
-The tool currently supports renaming actions inside a single Translation Unit
-only. It is planned to extend the tool's functionality to support multi-TU
-renaming actions in the future.
+Alternatively, old name / new name pairs can be put into a YAML file:
 
-:program:`clang-rename` also aims to be easily integrated into popular text
-editors, such as Vim and Emacs, and improve the workflow of users.
+.. code-block:: yaml
 
-Although a command line interface exists, it is highly recommended to use the
-text editor interface instead for better experience.
+  ---
+  - OldName:foo
+NewName:bar
+  ...
+
+
+That way you can avoid spelling out all the names as commandline arguments:
+
+.. code-block:: console
+
+  $ clang-rename rename-all -input=test.yaml test.cpp
+
+
+The YAML file also supports offsets:
+
+.. code-block:: yaml
+
+  ---
+  - Offset: 42
+NewName:foo
+  ...
+
+
+:program:`clang-rename` offers the following options:
 
 .. code-block:: console
 
@@ -125,6 +154,7 @@
 -extra-arg=- Additional argument to append to the compiler command line
 -extra-arg-before= - Additional argument to prepend to the compiler command line
 -i - Overwrite edited s.
+-input=- YAML file to load oldname-newname pairs from.
 -new-name= - The new name to change the symbol to.
 -offset= - Locates the symbol by offset as opposed to :.
 -old-name= - The fully qualified name of the symbol, if -offset is not used.
Index: clang-rename/tool/ClangRename.cpp
===
--- clang-rename/tool/ClangRename.cpp
+++ clang-rename/tool/ClangRename.cpp
@@ -56,6 +56,33 @@
 static int renameAllMain(int argc, const char *argv[]);
 static int helpMain(int argc, const char *argv[]);
 
+/// \brief An oldname -> newname rename.
+struct RenameAllInfo {
+  std::string OldName;
+  unsigned Offset;
+  std::string NewName;
+
+  RenameAllInfo() : Offset(0) {}
+};
+
+LLVM_YAML_IS_SEQUENCE_VECTOR(RenameAllInfo)
+
+namespace llvm {
+namespace yaml {
+
+/// \brief Specialized MappingTraits to describe how a RenameAllInfo is /
+/// (de)serialized.
+template <> struct MappingTraits {
+  static void mapping(IO , RenameAllInfo ) {
+IO.mapOptional("OldName", Info.OldName);
+IO.mapOptional("Offset", Info.Offset);
+IO.mapRequired("NewName", Info.NewName);
+  }
+};
+
+} // end namespace yaml
+} // end namespace llvm
+
 int main(int argc, const char **argv) {
   if (argc > 1) {
 using 

Re: [PATCH] D23167: emit_DW_AT_noreturn flag

2016-08-08 Thread Victor via cfe-commits
vleschuk updated this revision to Diff 67212.
vleschuk added a comment.

Added C++11, C11 and ObjC textual llvm-dwarfdump tests.


https://reviews.llvm.org/D23167

Files:
  include/llvm/IR/DebugInfoFlags.def
  include/llvm/IR/DebugInfoMetadata.h
  include/llvm/Support/Dwarf.h
  lib/CodeGen/AsmPrinter/DwarfUnit.cpp
  lib/Support/Dwarf.cpp
  test/DebugInfo/noreturn_c11.ll
  test/DebugInfo/noreturn_cpp11.ll
  test/DebugInfo/noreturn_objc.ll
  unittests/IR/DebugInfoTest.cpp

Index: unittests/IR/DebugInfoTest.cpp
===
--- unittests/IR/DebugInfoTest.cpp
+++ unittests/IR/DebugInfoTest.cpp
@@ -73,8 +73,9 @@
   CHECK_SPLIT(DINode::FlagRValueReference, {DINode::FlagRValueReference}, 0u);
   unsigned Flags[] = {DINode::FlagFwdDecl, DINode::FlagVector};
   CHECK_SPLIT(DINode::FlagFwdDecl | DINode::FlagVector, Flags, 0u);
-  CHECK_SPLIT(0x10u, {}, 0x10u);
-  CHECK_SPLIT(0x10u | DINode::FlagVector, {DINode::FlagVector}, 0x10u);
+  CHECK_SPLIT(0x20u, {}, 0x20u);
+  CHECK_SPLIT(0x20u | DINode::FlagVector, {DINode::FlagVector}, 0x20u);
+  CHECK_SPLIT(0x20u | DINode::FlagNoReturn, {DINode::FlagNoReturn}, 0x20u);
 #undef CHECK_SPLIT
 }
 
Index: test/DebugInfo/noreturn_objc.ll
===
--- /dev/null
+++ test/DebugInfo/noreturn_objc.ll
@@ -0,0 +1,50 @@
+; RUN: %llc_dwarf -filetype=obj < %s | llvm-dwarfdump -debug-dump=info - | FileCheck %s
+; REQUIRES: object-emission
+
+; Generated by clang++ -S -c --emit-llvm -g from the following ObjC source:
+; #include 
+; __attribute__ ((noreturn)) void f()
+; {
+;  exit(0);
+; }
+
+; CHECK:  DW_AT_noreturn
+
+; ModuleID = './test.m'
+source_filename = "./test.m"
+target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
+target triple = "x86_64-unknown-linux-gnu"
+
+; Function Attrs: noreturn nounwind uwtable
+define void @f() #0 !dbg !6 {
+entry:
+  call void @exit(i32 0) #2, !dbg !10
+  unreachable, !dbg !10
+
+return:   ; No predecessors!
+  ret void, !dbg !11
+}
+
+; Function Attrs: noreturn nounwind
+declare void @exit(i32) #1
+
+attributes #0 = { noreturn nounwind uwtable "disable-tail-calls"="false" "less-precise-fpmad"="false" "no-frame-pointer-elim"="true" "no-frame-pointer-elim-non-leaf" "no-infs-fp-math"="false" "no-jump-tables"="false" "no-nans-fp-math"="false" "no-signed-zeros-fp-math"="false" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+fxsr,+mmx,+sse,+sse2,+x87" "unsafe-fp-math"="false" "use-soft-float"="false" }
+attributes #1 = { noreturn nounwind "disable-tail-calls"="false" "less-precise-fpmad"="false" "no-frame-pointer-elim"="true" "no-frame-pointer-elim-non-leaf" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "no-signed-zeros-fp-math"="false" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+fxsr,+mmx,+sse,+sse2,+x87" "unsafe-fp-math"="false" "use-soft-float"="false" }
+attributes #2 = { noreturn nounwind }
+
+!llvm.dbg.cu = !{!0}
+!llvm.module.flags = !{!3, !4}
+!llvm.ident = !{!5}
+
+!0 = distinct !DICompileUnit(language: DW_LANG_ObjC, file: !1, producer: "clang version 4.0.0 (http://llvm.org/git/clang.git 08946d46f2add8cb241fdc09fc3731dd9dc5ecb5) (http://llvm.org/git/llvm.git d048aeecd34b8c336d1fd44e36c15b0b11c2ea4d)", isOptimized: false, runtimeVersion: 1, emissionKind: FullDebug, enums: !2)
+!1 = !DIFile(filename: "test.m", directory: "/home/del/test/noreturn/objc")
+!2 = !{}
+!3 = !{i32 2, !"Dwarf Version", i32 4}
+!4 = !{i32 2, !"Debug Info Version", i32 3}
+!5 = !{!"clang version 4.0.0 (http://llvm.org/git/clang.git 08946d46f2add8cb241fdc09fc3731dd9dc5ecb5) (http://llvm.org/git/llvm.git d048aeecd34b8c336d1fd44e36c15b0b11c2ea4d)"}
+!6 = distinct !DISubprogram(name: "f", scope: !7, file: !7, line: 2, type: !8, isLocal: false, isDefinition: true, scopeLine: 3, flags: DIFlagNoReturn, isOptimized: false, unit: !0, variables: !2)
+!7 = !DIFile(filename: "./test.m", directory: "/home/del/test/noreturn/objc")
+!8 = !DISubroutineType(types: !9)
+!9 = !{null}
+!10 = !DILocation(line: 4, column: 3, scope: !6)
+!11 = !DILocation(line: 5, column: 1, scope: !6)
Index: test/DebugInfo/noreturn_cpp11.ll
===
--- /dev/null
+++ test/DebugInfo/noreturn_cpp11.ll
@@ -0,0 +1,56 @@
+; RUN: %llc_dwarf -filetype=obj < %s | llvm-dwarfdump -debug-dump=info - | FileCheck %s
+; REQUIRES: object-emission
+
+; Generated by clang++ -S -c -std=c++11 --emit-llvm -g from the following C++11 source:
+; [[ noreturn ]] void f() {
+;   throw 1;
+; }
+
+; CHECK:  DW_AT_noreturn
+
+
+; ModuleID = 'test.cpp'
+source_filename = "test.cpp"
+target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
+target triple = "x86_64-unknown-linux-gnu"
+
+@_ZTIi = external constant i8*
+
+; Function Attrs: noreturn uwtable
+define void @_Z1fv() #0 

Re: [PATCH] D23016: Enhance treatment of function specializations in friend declarations

2016-08-08 Thread Serge Pavlov via cfe-commits
Ping.

Thanks,
--Serge

2016-08-01 21:47 GMT+07:00 Serge Pavlov :

> sepavloff created this revision.
> sepavloff added a subscriber: cfe-commits.
>
> Function specializations used in friend declarations in class templates,
> like:
> ```
> template class C1 {
> friend void func<>(int);
> ```
> previously were processed incorrectly: class instantiation made them
> ordinary
> functions and they were not placed into redeclaration chains correctly.
> This
> change repairs specialization treatment.
>
> This change fixes PR12994.
>
> https://reviews.llvm.org/D23016
>
> Files:
>   lib/AST/DeclTemplate.cpp
>   lib/Sema/SemaAccess.cpp
>   lib/Sema/SemaTemplateInstantiateDecl.cpp
>   test/SemaCXX/friend-spec.cpp
>
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D23112: [analyzer] Correctly add assumptions based on array bounds.

2016-08-08 Thread Artem Dergachev via cfe-commits
NoQ accepted this revision.
This revision is now accepted and ready to land.


Comment at: test/Analysis/out-of-bounds.c:153
@@ +152,3 @@
+// The result is unknown for the same reason as above.
+void test_asume_after_access(unsigned long x) {
+  int buf[100];

Yay, there already was a test for this.

/asume/assume/ here and below?


https://reviews.llvm.org/D23112



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


Re: [PATCH] D23241: Add the notion of deferred diagnostics.

2016-08-08 Thread Artem Belevich via cfe-commits
tra added inline comments.


Comment at: clang/lib/CodeGen/CodeGenModule.cpp:2886
@@ +2885,3 @@
+  // Check if this function has diagnostics that should be emitted when we
+  // codegen it.  If so, don't eit this function definition, but don't emit the
+  // diags just yet.  Emitting an error during codegen stops codegen, and we

eit->emit.  
"don't do X, but don't do Y" construction sounds awkward to me.
I'd reword the whole comment in terms of what the code does -- if there are 
diagnostics, only collect them to emit at the end of codegen. Otherwise, 
proceed to emit function definition.



https://reviews.llvm.org/D23241



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


[libcxx] r278032 - CMakeLists.txt cleanups: synchronize version with rest of LLVM, consistent spacing.

2016-08-08 Thread Eugene Zelenko via cfe-commits
Author: eugenezelenko
Date: Mon Aug  8 13:01:50 2016
New Revision: 278032

URL: http://llvm.org/viewvc/llvm-project?rev=278032=rev
Log:
CMakeLists.txt cleanups: synchronize version with rest of LLVM, consistent 
spacing.

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

Modified:
libcxx/trunk/CMakeLists.txt

Modified: libcxx/trunk/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/CMakeLists.txt?rev=278032=278031=278032=diff
==
--- libcxx/trunk/CMakeLists.txt (original)
+++ libcxx/trunk/CMakeLists.txt Mon Aug  8 13:01:50 2016
@@ -26,10 +26,10 @@ if (LIBCXX_BUILT_STANDALONE)
   project(libcxx CXX C)
 
   set(PACKAGE_NAME libcxx)
-  set(PACKAGE_VERSION trunk-svn)
+  set(PACKAGE_VERSION 4.0.0svn)
   set(PACKAGE_STRING "${PACKAGE_NAME} ${PACKAGE_VERSION}")
   set(PACKAGE_BUGREPORT "llvm-b...@lists.llvm.org")
-endif ()
+endif()
 
 if (LIBCXX_BUILT_STANDALONE AND NOT LLVM_FOUND)
   message(WARNING "UNSUPPORTED LIBCXX CONFIGURATION DETECTED: "
@@ -81,12 +81,12 @@ if (NOT LIBCXX_CXX_ABI)
 set(LIBCXX_CXX_ABI_LIBNAME "libcxxabi")
 set(LIBCXX_CXX_ABI_INCLUDE_PATHS 
"${CMAKE_SOURCE_DIR}/projects/libcxxabi/include")
 set(LIBCXX_CXX_ABI_INTREE 1)
-  else ()
+  else()
 set(LIBCXX_CXX_ABI_LIBNAME "none")
-  endif ()
-else ()
+  endif()
+else()
   set(LIBCXX_CXX_ABI_LIBNAME "${LIBCXX_CXX_ABI}")
-endif ()
+endif()
 
 # Use a static copy of the ABI library when linking libc++. This option
 # cannot be used with LIBCXX_ENABLE_ABI_LINKER_SCRIPT.
@@ -307,7 +307,6 @@ endif()
 # headers
 add_compile_flags_if_supported(-nostdinc++)
 
-
 # Warning flags ===
 add_definitions(-D_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
 add_compile_flags_if_supported(


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


Re: [PATCH] D23240: [CUDA] Print a "previous-decl" note when calling an illegal member fn.

2016-08-08 Thread Artem Belevich via cfe-commits
tra accepted this revision.
tra added a comment.
This revision is now accepted and ready to land.

LGTM.


https://reviews.llvm.org/D23240



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


[libcxxabi] r278030 - CMakeLists.txt cleanups: synchronize version with rest of LLVM, consistent spacing.

2016-08-08 Thread Eugene Zelenko via cfe-commits
Author: eugenezelenko
Date: Mon Aug  8 12:59:02 2016
New Revision: 278030

URL: http://llvm.org/viewvc/llvm-project?rev=278030=rev
Log:
CMakeLists.txt cleanups: synchronize version with rest of LLVM, consistent 
spacing.

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

Modified:
libcxxabi/trunk/CMakeLists.txt

Modified: libcxxabi/trunk/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/libcxxabi/trunk/CMakeLists.txt?rev=278030=278029=278030=diff
==
--- libcxxabi/trunk/CMakeLists.txt (original)
+++ libcxxabi/trunk/CMakeLists.txt Mon Aug  8 12:59:02 2016
@@ -64,7 +64,7 @@ if (CMAKE_SOURCE_DIR STREQUAL CMAKE_CURR
   endif()
 
   set(PACKAGE_NAME libcxxabi)
-  set(PACKAGE_VERSION 3.7.0svn)
+  set(PACKAGE_VERSION 4.0.0svn)
   set(PACKAGE_STRING "${PACKAGE_NAME} ${PACKAGE_VERSION}")
   set(PACKAGE_BUGREPORT "llvm-b...@lists.llvm.org")
 
@@ -189,8 +189,7 @@ set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${LIB
 if (NOT LIBCXXABI_LIBCXX_LIBRARY_PATH)
   set(LIBCXXABI_LIBCXX_LIBRARY_PATH "${LIBCXXABI_LIBRARY_DIR}" CACHE PATH
   "The path to libc++ library.")
-endif ()
-
+endif()
 
 # Check that we can build with 32 bits if requested.
 if (CMAKE_SIZEOF_VOID_P EQUAL 8 AND NOT WIN32)
@@ -246,7 +245,7 @@ endif()
 
 if (LIBCXXABI_USE_COMPILER_RT)
   list(APPEND LIBCXXABI_LINK_FLAGS "-rtlib=compiler-rt")
-endif ()
+endif()
 
 append_if(LIBCXXABI_COMPILE_FLAGS LIBCXXABI_HAS_WERROR_FLAG 
-Werror=return-type)
 
@@ -383,7 +382,7 @@ if (LIBCXXABI_USE_LLVM_UNWINDER OR LLVM_
 
   include_directories("${LIBCXXABI_LIBUNWIND_INCLUDES_INTERNAL}")
   include_directories("${LIBCXXABI_LIBUNWIND_SOURCES}")
-endif ()
+endif()
 
 # Add source code. This also contains all of the logic for deciding linker 
flags
 # soname, etc...


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


Re: [PATCH] D23239: [CUDA] Add __device__ overloads for placement new and delete.

2016-08-08 Thread Artem Belevich via cfe-commits
tra added a comment.

I think we need to add `noexcept` for these in c++11.


https://reviews.llvm.org/D23239



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


[libunwind] r278029 - CMakeLists.txt cleanups: synchronize version and CMake minimum required version with rest of LLVM, consistent spacing.

2016-08-08 Thread Eugene Zelenko via cfe-commits
Author: eugenezelenko
Date: Mon Aug  8 12:56:28 2016
New Revision: 278029

URL: http://llvm.org/viewvc/llvm-project?rev=278029=rev
Log:
CMakeLists.txt cleanups: synchronize version and CMake minimum required version 
with rest of LLVM, consistent spacing.

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

Modified:
libunwind/trunk/CMakeLists.txt

Modified: libunwind/trunk/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/libunwind/trunk/CMakeLists.txt?rev=278029=278028=278029=diff
==
--- libunwind/trunk/CMakeLists.txt (original)
+++ libunwind/trunk/CMakeLists.txt Mon Aug  8 12:56:28 2016
@@ -2,7 +2,7 @@
 # Setup Project
 
#===
 
-cmake_minimum_required(VERSION 2.8.8)
+cmake_minimum_required(VERSION 3.4.3)
 
 if (POLICY CMP0042)
   cmake_policy(SET CMP0042 NEW) # Set MACOSX_RPATH=YES by default
@@ -28,11 +28,11 @@ if (CMAKE_SOURCE_DIR STREQUAL CMAKE_CURR
 if (NOT HAD_ERROR)
   string(REGEX REPLACE "[ \t]*[\r\n]+[ \t]*" ";"
  CONFIG_OUTPUT ${CONFIG_OUTPUT})
-else ()
+else()
   string(REPLACE ";" " " CONFIG_COMMAND_STR "${CONFIG_COMMAND}")
   message(STATUS "${CONFIG_COMMAND_STR}")
   message(FATAL_ERROR "llvm-config failed with status ${HAD_ERROR}")
-endif ()
+endif()
 
 list(GET CONFIG_OUTPUT 0 INCLUDE_DIR)
 list(GET CONFIG_OUTPUT 1 LLVM_OBJ_ROOT)
@@ -43,32 +43,32 @@ if (CMAKE_SOURCE_DIR STREQUAL CMAKE_CURR
 set(LLVM_MAIN_SRC_DIR ${MAIN_SRC_DIR} CACHE PATH "Path to LLVM source 
tree")
 set(LLVM_CMAKE_PATH 
"${LLVM_BINARY_DIR}/lib${LLVM_LIBDIR_SUFFIX}/cmake/llvm")
 set(LLVM_LIT_PATH "${LLVM_PATH}/utils/lit/lit.py")
-  else ()
+  else()
 message(FATAL_ERROR "llvm-config not found and LLVM_MAIN_SRC_DIR not 
defined. "
 "Reconfigure with -DLLVM_CONFIG=path/to/llvm-config "
 "or -DLLVM_PATH=path/to/llvm-source-root.")
-  endif ()
+  endif()
 
   if (EXISTS ${LLVM_CMAKE_PATH})
 list(APPEND CMAKE_MODULE_PATH "${LLVM_CMAKE_PATH}")
 include("${LLVM_CMAKE_PATH}/AddLLVM.cmake")
 include("${LLVM_CMAKE_PATH}/HandleLLVMOptions.cmake")
-  else ()
+  else()
 message(FATAL_ERROR "Not found: ${LLVM_CMAKE_PATH}")
-  endif ()
+  endif()
 
   set(PACKAGE_NAME libunwind)
-  set(PACKAGE_VERSION 3.8.0svn)
+  set(PACKAGE_VERSION 4.0.0svn)
   set(PACKAGE_STRING "${PACKAGE_NAME} ${PACKAGE_VERSION}")
   set(PACKAGE_BUGREPORT "llvm-b...@lists.llvm.org")
 
   if (EXISTS ${LLVM_MAIN_SRC_DIR}/utils/lit/lit.py)
 set(LLVM_LIT ${LLVM_MAIN_SRC_DIR}/utils/lit/lit.py)
-  else ()
+  else()
 # Seek installed Lit.
 find_program(LLVM_LIT "lit.py" ${LLVM_MAIN_SRC_DIR}/utils/lit
  DOC "Path to lit.py")
-  endif ()
+  endif()
 
   if (LLVM_LIT)
 # Define the default arguments to use with 'lit', and an option for the 
user
@@ -76,16 +76,16 @@ if (CMAKE_SOURCE_DIR STREQUAL CMAKE_CURR
 set(LIT_ARGS_DEFAULT "-sv")
 if (MSVC OR XCODE)
   set(LIT_ARGS_DEFAULT "${LIT_ARGS_DEFAULT} --no-progress-bar")
-endif ()
+endif()
 set(LLVM_LIT_ARGS "${LIT_ARGS_DEFAULT}" CACHE STRING "Default options for 
lit")
 
 # On Win32 hosts, provide an option to specify the path to the GnuWin32 
tools.
 if (WIN32 AND NOT CYGWIN)
   set(LLVM_LIT_TOOLS_DIR "" CACHE PATH "Path to GnuWin32 tools")
-endif ()
-  else ()
+endif()
+  else()
 set(LLVM_INCLUDE_TESTS OFF)
-  endif ()
+  endif()
 
   set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY 
${CMAKE_BINARY_DIR}/lib${LLVM_LIBDIR_SUFFIX})
   set(CMAKE_LIBRARY_OUTPUT_DIRECTORY 
${CMAKE_BINARY_DIR}/lib${LLVM_LIBDIR_SUFFIX})
@@ -111,7 +111,6 @@ set(LIBUNWIND_TARGET_TRIPLE "" CACHE STR
 set(LIBUNWIND_GCC_TOOLCHAIN "" CACHE PATH "GCC toolchain for cross compiling.")
 set(LIBUNWIND_SYSROOT "" CACHE PATH "Sysroot for cross compiling.")
 
-
 # Check that we can build with 32 bits if requested.
 if (CMAKE_SIZEOF_VOID_P EQUAL 8 AND NOT WIN32)
   if (LIBUNWIND_BUILD_32_BITS AND NOT LLVM_BUILD_32_BITS) # Don't duplicate 
the output from LLVM
@@ -220,23 +219,23 @@ if (LIBUNWIND_ENABLE_ASSERTIONS)
   # MSVC doesn't like _DEBUG on release builds. See PR 4379.
   if (NOT MSVC)
 list(APPEND LIBUNWIND_COMPILE_FLAGS -D_DEBUG)
-  endif ()
+  endif()
 
   # On Release builds cmake automatically defines NDEBUG, so we
   # explicitly undefine it:
   if (uppercase_CMAKE_BUILD_TYPE STREQUAL "RELEASE")
 list(APPEND LIBUNWIND_COMPILE_FLAGS -UNDEBUG)
-  endif ()
+  endif()
 else()
   if (NOT uppercase_CMAKE_BUILD_TYPE STREQUAL "RELEASE")
 list(APPEND LIBUNWIND_COMPILE_FLAGS -DNDEBUG)
-  endif ()
-endif ()
+  endif()
+endif()
 
 # Cross-unwinding
 if (NOT LIBUNWIND_ENABLE_CROSS_UNWINDING)
   list(APPEND LIBUNWIND_COMPILE_FLAGS -D_LIBUNWIND_IS_NATIVE_ONLY)
-endif ()
+endif()
 
 # ARM WMMX register support
 if (LIBUNWIND_ENABLE_ARM_WMMX)
@@ -245,12 +244,12 @@ if (LIBUNWIND_ENABLE_ARM_WMMX)

Re: [PATCH] D23238: [CUDA] Rename CheckCUDATarget to IsAllowedCUDACall. NFC

2016-08-08 Thread Artem Belevich via cfe-commits
tra accepted this revision.
tra added a comment.
This revision is now accepted and ready to land.

LGTM.


https://reviews.llvm.org/D23238



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


Re: [PATCH] D22729: MPIBufferDerefCheck for Clang-Tidy

2016-08-08 Thread Alexander Droste via cfe-commits
Alexander_Droste added a comment.

Great; thanks again for the review!


https://reviews.llvm.org/D22729



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


Re: [PATCH] D23243: [clang-tidy] enhance modernize-use-bool-literals to check ternary operator

2016-08-08 Thread Kirill Bobyrev via cfe-commits
omtcyfz updated this revision to Diff 67195.
omtcyfz added a comment.

More strict test messages.


https://reviews.llvm.org/D23243

Files:
  clang-tidy/modernize/UseBoolLiteralsCheck.cpp
  docs/clang-tidy/checks/modernize-use-bool-literals.rst
  test/clang-tidy/modernize-use-bool-literals.cpp

Index: test/clang-tidy/modernize-use-bool-literals.cpp
===
--- test/clang-tidy/modernize-use-bool-literals.cpp
+++ test/clang-tidy/modernize-use-bool-literals.cpp
@@ -5,39 +5,39 @@
 // CHECK-FIXES: {{^}}bool IntToTrue = true;{{$}}
 
 bool IntToFalse(0);
-// CHECK-MESSAGES: :[[@LINE-1]]:17: warning: {{.*}}
+// CHECK-MESSAGES: :[[@LINE-1]]:17: warning: converting integer literal to bool
 // CHECK-FIXES: {{^}}bool IntToFalse(false);{{$}}
 
 bool LongLongToTrue{0x1LL};
-// CHECK-MESSAGES: :[[@LINE-1]]:21: warning: {{.*}}
+// CHECK-MESSAGES: :[[@LINE-1]]:21: warning: converting integer literal to bool
 // CHECK-FIXES: {{^}}bool LongLongToTrue{true};{{$}}
 
 bool ExplicitCStyleIntToFalse = (bool)0;
-// CHECK-MESSAGES: :[[@LINE-1]]:33: warning: {{.*}}
+// CHECK-MESSAGES: :[[@LINE-1]]:33: warning: converting integer literal to bool
 // CHECK-FIXES: {{^}}bool ExplicitCStyleIntToFalse = false;{{$}}
 
 bool ExplicitFunctionalIntToFalse = bool(0);
-// CHECK-MESSAGES: :[[@LINE-1]]:37: warning: {{.*}}
+// CHECK-MESSAGES: :[[@LINE-1]]:37: warning: converting integer literal to bool
 // CHECK-FIXES: {{^}}bool ExplicitFunctionalIntToFalse = false;{{$}}
 
 bool ExplicitStaticIntToFalse = static_cast(0);
-// CHECK-MESSAGES: :[[@LINE-1]]:33: warning: {{.*}}
+// CHECK-MESSAGES: :[[@LINE-1]]:33: warning: converting integer literal to bool
 // CHECK-FIXES: {{^}}bool ExplicitStaticIntToFalse = false;{{$}}
 
 #define TRUE_MACRO 1
 // CHECK-FIXES: {{^}}#define TRUE_MACRO 1{{$}}
 
 bool MacroIntToTrue = TRUE_MACRO;
-// CHECK-MESSAGES: :[[@LINE-1]]:23: warning: converting integer literal to bool, use bool literal instead [modernize-use-bool-literals]
+// CHECK-MESSAGES: :[[@LINE-1]]:23: warning: converting integer literal to bool
 // CHECK-FIXES: {{^}}bool MacroIntToTrue = TRUE_MACRO;{{$}}
 
 #define FALSE_MACRO bool(0)
 // CHECK-FIXES: {{^}}#define FALSE_MACRO bool(0){{$}}
 
 bool TrueBool = true; // OK
 
 bool FalseBool = bool(FALSE_MACRO);
-// CHECK-MESSAGES: :[[@LINE-1]]:23: warning: {{.*}}
+// CHECK-MESSAGES: :[[@LINE-1]]:23: warning: converting integer literal to bool
 // CHECK-FIXES: {{^}}bool FalseBool = bool(FALSE_MACRO);{{$}}
 
 void boolFunction(bool bar) {
@@ -52,28 +52,28 @@
 // CHECK-FIXES: {{^}}#define MACRO_DEPENDENT_CAST(x) static_cast(x){{$}}
 
 bool MacroDependentBool = MACRO_DEPENDENT_CAST(0);
-// CHECK-MESSAGES: :[[@LINE-1]]:27: warning: {{.*}}
+// CHECK-MESSAGES: :[[@LINE-1]]:27: warning: converting integer literal to bool
 // CHECK-FIXES: {{^}}bool MacroDependentBool = MACRO_DEPENDENT_CAST(0);{{$}}
 
 bool ManyMacrosDependent = MACRO_DEPENDENT_CAST(FALSE_MACRO);
-// CHECK-MESSAGES: :[[@LINE-1]]:49: warning: {{.*}}
+// CHECK-MESSAGES: :[[@LINE-1]]:49: warning: converting integer literal to bool
 // CHECK-FIXES: {{^}}bool ManyMacrosDependent = MACRO_DEPENDENT_CAST(FALSE_MACRO);{{$}}
 
 class FooClass {
   public:
   FooClass() : JustBool(0) {}
-  // CHECK-MESSAGES: :[[@LINE-1]]:25: warning: {{.*}}
+  // CHECK-MESSAGES: :[[@LINE-1]]:25: warning: converting integer literal to bool
   // CHECK-FIXES: {{^ *}}FooClass() : JustBool(false) {}{{$}}
   FooClass(int) : JustBool{0} {}
-  // CHECK-MESSAGES: :[[@LINE-1]]:28: warning: {{.*}}
+  // CHECK-MESSAGES: :[[@LINE-1]]:28: warning: converting integer literal to bool
   // CHECK-FIXES: {{^ *}}FooClass(int) : JustBool{false} {}{{$}}
   private:
   bool JustBool;
   bool BoolWithBraces{0};
-  // CHECK-MESSAGES: :[[@LINE-1]]:23: warning: {{.*}}
+  // CHECK-MESSAGES: :[[@LINE-1]]:23: warning: converting integer literal to bool
   // CHECK-FIXES: {{^ *}}bool BoolWithBraces{false};{{$}}
   bool BoolFromInt = 0;
-  // CHECK-MESSAGES: :[[@LINE-1]]:22: warning: {{.*}}
+  // CHECK-MESSAGES: :[[@LINE-1]]:22: warning: converting integer literal to bool
   // CHECK-FIXES: {{^ *}}bool BoolFromInt = false;{{$}}
   bool SimpleBool = true; // OK
 };
@@ -93,13 +93,13 @@
 template
 void anotherTemplateFunction(type) {
   bool JustBool = 0;
-  // CHECK-MESSAGES: :[[@LINE-1]]:19: warning: {{.*}}
+  // CHECK-MESSAGES: :[[@LINE-1]]:19: warning: converting integer literal to bool
   // CHECK-FIXES: {{^ *}}bool JustBool = false;{{$}}
 }
 
 int main() {
   boolFunction(1);
-  // CHECK-MESSAGES: :[[@LINE-1]]:16: warning: {{.*}}
+  // CHECK-MESSAGES: :[[@LINE-1]]:16: warning: converting integer literal to bool
   // CHECK-FIXES: {{^ *}}boolFunction(true);{{$}}
 
   boolFunction(false);
@@ -113,6 +113,36 @@
   anotherTemplateFunction(1);
 
   IntToTrue = 1;
-  // CHECK-MESSAGES: :[[@LINE-1]]:15: warning: {{.*}}
+  // CHECK-MESSAGES: :[[@LINE-1]]:15: warning: converting integer literal to bool
   // CHECK-FIXES: {{^ *}}IntToTrue = true;{{$}}
 }
+

Re: [PATCH] D23193: [clang-rename] fix bug with initializer lists

2016-08-08 Thread Kirill Bobyrev via cfe-commits
omtcyfz updated this revision to Diff 67199.
omtcyfz added a comment.

Added more info to the test.


https://reviews.llvm.org/D23193

Files:
  clang-rename/USRFinder.cpp
  clang-rename/USRLocFinder.cpp
  test/clang-rename/Field.cpp

Index: test/clang-rename/Field.cpp
===
--- test/clang-rename/Field.cpp
+++ test/clang-rename/Field.cpp
@@ -1,14 +1,15 @@
-// RUN: cat %s > %t.cpp
-// RUN: clang-rename -offset=148 -new-name=Bar %t.cpp -i --
-// RUN: sed 's,//.*,,' %t.cpp | FileCheck %s
-
 class Baz {
-  int Foo;  // CHECK: Bar;
+  int Foo; /* Test 1 */ // CHECK: int Bar;
 public:
   Baz();
 };
 
-Baz::Baz() : Foo(0) {}  // CHECK: Baz::Baz() : Bar(0) {}
+Baz::Baz() : Foo(0) /* Test 2 */ {}  // CHECK: Baz::Baz() : Bar(0)
+
+// Test 1.
+// RUN: clang-rename -offset=18 -new-name=Bar %s -- | sed 's,//.*,,' | 
FileCheck %s
+// Test 2.
+// RUN: clang-rename -offset=89 -new-name=Bar %s -- | sed 's,//.*,,' | 
FileCheck %s
 
-// Use grep -FUbo 'Foo'  to get the correct offset of foo when changing
-// this file.
+// To find offsets after modifying the file, use:
+//   grep -Ubo 'Foo.*' 
Index: clang-rename/USRLocFinder.cpp
===
--- clang-rename/USRLocFinder.cpp
+++ clang-rename/USRLocFinder.cpp
@@ -48,18 +48,9 @@
 // Ignore implicit initializers.
 continue;
   }
-  if (const clang::FieldDecl *FieldDecl = Initializer->getAnyMember()) {
+  if (const clang::FieldDecl *FieldDecl = Initializer->getMember()) {
 if (USRSet.find(getUSRForDecl(FieldDecl)) != USRSet.end()) {
-  // The initializer refers to a field that is to be renamed.
-  SourceLocation Location = Initializer->getSourceLocation();
-  StringRef TokenName = Lexer::getSourceText(
-  CharSourceRange::getTokenRange(Location),
-  Context.getSourceManager(), Context.getLangOpts());
-  if (TokenName == PrevName) {
-// The token of the source location we find actually has the old
-// name.
-LocationsFound.push_back(Initializer->getSourceLocation());
-  }
+  LocationsFound.push_back(Initializer->getSourceLocation());
 }
   }
 }
Index: clang-rename/USRFinder.cpp
===
--- clang-rename/USRFinder.cpp
+++ clang-rename/USRFinder.cpp
@@ -90,6 +90,24 @@
  TypeEndLoc);
   }
 
+  bool VisitCXXConstructorDecl(clang::CXXConstructorDecl *ConstructorDecl) {
+for (auto  : ConstructorDecl->inits()) {
+  if (Initializer->getSourceOrder() == -1) {
+// Ignore implicit initializers.
+continue;
+  }
+  if (const clang::FieldDecl *FieldDecl = Initializer->getMember()) {
+const auto InitBeginLoc = Initializer->getSourceLocation();
+const auto InitEndLoc = Lexer::getLocForEndOfToken(
+InitBeginLoc, 0, Context.getSourceManager(), 
Context.getLangOpts());
+if (!setResult(FieldDecl, InitBeginLoc, InitEndLoc)) {
+  return false;
+}
+  }
+}
+return true;
+  }
+
   // Other:
 
   const NamedDecl *getNamedDecl() { return Result; }


Index: test/clang-rename/Field.cpp
===
--- test/clang-rename/Field.cpp
+++ test/clang-rename/Field.cpp
@@ -1,14 +1,15 @@
-// RUN: cat %s > %t.cpp
-// RUN: clang-rename -offset=148 -new-name=Bar %t.cpp -i --
-// RUN: sed 's,//.*,,' %t.cpp | FileCheck %s
-
 class Baz {
-  int Foo;  // CHECK: Bar;
+  int Foo; /* Test 1 */ // CHECK: int Bar;
 public:
   Baz();
 };
 
-Baz::Baz() : Foo(0) {}  // CHECK: Baz::Baz() : Bar(0) {}
+Baz::Baz() : Foo(0) /* Test 2 */ {}  // CHECK: Baz::Baz() : Bar(0)
+
+// Test 1.
+// RUN: clang-rename -offset=18 -new-name=Bar %s -- | sed 's,//.*,,' | FileCheck %s
+// Test 2.
+// RUN: clang-rename -offset=89 -new-name=Bar %s -- | sed 's,//.*,,' | FileCheck %s
 
-// Use grep -FUbo 'Foo'  to get the correct offset of foo when changing
-// this file.
+// To find offsets after modifying the file, use:
+//   grep -Ubo 'Foo.*' 
Index: clang-rename/USRLocFinder.cpp
===
--- clang-rename/USRLocFinder.cpp
+++ clang-rename/USRLocFinder.cpp
@@ -48,18 +48,9 @@
 // Ignore implicit initializers.
 continue;
   }
-  if (const clang::FieldDecl *FieldDecl = Initializer->getAnyMember()) {
+  if (const clang::FieldDecl *FieldDecl = Initializer->getMember()) {
 if (USRSet.find(getUSRForDecl(FieldDecl)) != USRSet.end()) {
-  // The initializer refers to a field that is to be renamed.
-  SourceLocation Location = Initializer->getSourceLocation();
-  StringRef TokenName = Lexer::getSourceText(
-  CharSourceRange::getTokenRange(Location),
-  Context.getSourceManager(), Context.getLangOpts());

Re: [libunwind] r277868 - unwind: disable executable stacks

2016-08-08 Thread Hans Wennborg via cfe-commits
Okay, r278023.

Thanks,
Hans

On Fri, Aug 5, 2016 at 2:46 PM, Saleem Abdulrasool
 wrote:
> On Fri, Aug 5, 2016 at 2:35 PM, Saleem Abdulrasool via cfe-commits
>  wrote:
>>
>> Author: compnerd
>> Date: Fri Aug  5 16:35:28 2016
>> New Revision: 277868
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=277868=rev
>> Log:
>> unwind: disable executable stacks
>>
>> Similar to compiler-rt, ensure that we disable executable stacks for the
>> custom
>> assembly.
>
>
> Hi Hans,
>
> I think that we should get this merged into 3.9.
>
>>
>>
>> Modified:
>> libunwind/trunk/src/UnwindRegistersRestore.S
>> libunwind/trunk/src/UnwindRegistersSave.S
>> libunwind/trunk/src/assembly.h
>>
>> Modified: libunwind/trunk/src/UnwindRegistersRestore.S
>> URL:
>> http://llvm.org/viewvc/llvm-project/libunwind/trunk/src/UnwindRegistersRestore.S?rev=277868=277867=277868=diff
>>
>> ==
>> --- libunwind/trunk/src/UnwindRegistersRestore.S (original)
>> +++ libunwind/trunk/src/UnwindRegistersRestore.S Fri Aug  5 16:35:28 2016
>> @@ -488,3 +488,6 @@ DEFINE_LIBUNWIND_PRIVATE_FUNCTION(_ZN9li
>> l.nop
>>
>>  #endif
>> +
>> +NO_EXEC_STACK_DIRECTIVE
>> +
>>
>> Modified: libunwind/trunk/src/UnwindRegistersSave.S
>> URL:
>> http://llvm.org/viewvc/llvm-project/libunwind/trunk/src/UnwindRegistersSave.S?rev=277868=277867=277868=diff
>>
>> ==
>> --- libunwind/trunk/src/UnwindRegistersSave.S (original)
>> +++ libunwind/trunk/src/UnwindRegistersSave.S Fri Aug  5 16:35:28 2016
>> @@ -468,3 +468,6 @@ DEFINE_LIBUNWIND_FUNCTION(unw_getcontext
>>l.sw 120(r3), r30
>>l.sw 124(r3), r31
>>  #endif
>> +
>> +NO_EXEC_STACK_DIRECTIVE
>> +
>>
>> Modified: libunwind/trunk/src/assembly.h
>> URL:
>> http://llvm.org/viewvc/llvm-project/libunwind/trunk/src/assembly.h?rev=277868=277867=277868=diff
>>
>> ==
>> --- libunwind/trunk/src/assembly.h (original)
>> +++ libunwind/trunk/src/assembly.h Fri Aug  5 16:35:28 2016
>> @@ -35,19 +35,34 @@
>>  #define SYMBOL_NAME(name) GLUE(__USER_LABEL_PREFIX__, name)
>>
>>  #if defined(__APPLE__)
>> +
>>  #define SYMBOL_IS_FUNC(name)
>> +#define NO_EXEC_STACK_DIRECTIVE
>> +
>>  #elif defined(__ELF__)
>> +
>>  #if defined(__arm__)
>>  #define SYMBOL_IS_FUNC(name) .type name,%function
>>  #else
>>  #define SYMBOL_IS_FUNC(name) .type name,@function
>>  #endif
>> +
>> +#if defined(__GNU__) || defined(__ANDROID__) || defined(__FreeBSD__)
>> +#define NO_EXEC_STACK_DIRECTIVE .section .note.GNU-stack,"",%progbits
>> +#else
>> +#define NO_EXEC_STACK_DIRECTIVE
>> +#endif
>> +
>>  #else
>> +
>>  #define SYMBOL_IS_FUNC(name)
>> \
>>.def name SEPARATOR
>> \
>>  .scl 2 SEPARATOR
>> \
>>  .type 32 SEPARATOR
>> \
>>.endef
>> +
>> +#define NO_EXEC_STACK_DIRECTIVE
>> +
>>  #endif
>>
>>  #define DEFINE_LIBUNWIND_FUNCTION(name)   \
>>
>>
>> ___
>> cfe-commits mailing list
>> cfe-commits@lists.llvm.org
>> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>
>
>
>
> --
> Saleem Abdulrasool
> compnerd (at) compnerd (dot) org
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[libunwind] r278023 - Merging r277868:

2016-08-08 Thread Hans Wennborg via cfe-commits
Author: hans
Date: Mon Aug  8 12:18:56 2016
New Revision: 278023

URL: http://llvm.org/viewvc/llvm-project?rev=278023=rev
Log:
Merging r277868:

r277868 | compnerd | 2016-08-05 14:35:28 -0700 (Fri, 05 Aug 2016) | 4 lines

unwind: disable executable stacks

Similar to compiler-rt, ensure that we disable executable stacks for the custom
assembly.


Modified:
libunwind/branches/release_39/   (props changed)
libunwind/branches/release_39/src/UnwindRegistersRestore.S
libunwind/branches/release_39/src/UnwindRegistersSave.S
libunwind/branches/release_39/src/assembly.h

Propchange: libunwind/branches/release_39/
--
--- svn:mergeinfo (original)
+++ svn:mergeinfo Mon Aug  8 12:18:56 2016
@@ -1 +1 @@
-/libunwind/trunk:276128
+/libunwind/trunk:276128,277868

Modified: libunwind/branches/release_39/src/UnwindRegistersRestore.S
URL: 
http://llvm.org/viewvc/llvm-project/libunwind/branches/release_39/src/UnwindRegistersRestore.S?rev=278023=278022=278023=diff
==
--- libunwind/branches/release_39/src/UnwindRegistersRestore.S (original)
+++ libunwind/branches/release_39/src/UnwindRegistersRestore.S Mon Aug  8 
12:18:56 2016
@@ -479,3 +479,6 @@ DEFINE_LIBUNWIND_PRIVATE_FUNCTION(_ZN9li
l.nop
 
 #endif
+
+NO_EXEC_STACK_DIRECTIVE
+

Modified: libunwind/branches/release_39/src/UnwindRegistersSave.S
URL: 
http://llvm.org/viewvc/llvm-project/libunwind/branches/release_39/src/UnwindRegistersSave.S?rev=278023=278022=278023=diff
==
--- libunwind/branches/release_39/src/UnwindRegistersSave.S (original)
+++ libunwind/branches/release_39/src/UnwindRegistersSave.S Mon Aug  8 12:18:56 
2016
@@ -464,3 +464,6 @@ DEFINE_LIBUNWIND_FUNCTION(unw_getcontext
   l.sw 120(r3), r30
   l.sw 124(r3), r31
 #endif
+
+NO_EXEC_STACK_DIRECTIVE
+

Modified: libunwind/branches/release_39/src/assembly.h
URL: 
http://llvm.org/viewvc/llvm-project/libunwind/branches/release_39/src/assembly.h?rev=278023=278022=278023=diff
==
--- libunwind/branches/release_39/src/assembly.h (original)
+++ libunwind/branches/release_39/src/assembly.h Mon Aug  8 12:18:56 2016
@@ -35,19 +35,34 @@
 #define SYMBOL_NAME(name) GLUE(__USER_LABEL_PREFIX__, name)
 
 #if defined(__APPLE__)
+
 #define SYMBOL_IS_FUNC(name)
+#define NO_EXEC_STACK_DIRECTIVE
+
 #elif defined(__ELF__)
+
 #if defined(__arm__)
 #define SYMBOL_IS_FUNC(name) .type name,%function
 #else
 #define SYMBOL_IS_FUNC(name) .type name,@function
 #endif
+
+#if defined(__GNU__) || defined(__ANDROID__) || defined(__FreeBSD__)
+#define NO_EXEC_STACK_DIRECTIVE .section .note.GNU-stack,"",%progbits
+#else
+#define NO_EXEC_STACK_DIRECTIVE
+#endif
+
 #else
+
 #define SYMBOL_IS_FUNC(name)   
\
   .def name SEPARATOR  
\
 .scl 2 SEPARATOR   
\
 .type 32 SEPARATOR 
\
   .endef
+
+#define NO_EXEC_STACK_DIRECTIVE
+
 #endif
 
 #define DEFINE_LIBUNWIND_FUNCTION(name)   \


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


Re: [PATCH] D23243: [clang-tidy] enhance modernize-use-bool-literals to check ternary operator

2016-08-08 Thread Kirill Bobyrev via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL278022: [clang-tidy] enhance modernize-use-bool-literals to 
check ternary operator (authored by omtcyfz).

Changed prior to commit:
  https://reviews.llvm.org/D23243?vs=67195=67197#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D23243

Files:
  clang-tools-extra/trunk/clang-tidy/modernize/UseBoolLiteralsCheck.cpp
  clang-tools-extra/trunk/docs/clang-tidy/checks/modernize-use-bool-literals.rst
  clang-tools-extra/trunk/test/clang-tidy/modernize-use-bool-literals.cpp

Index: clang-tools-extra/trunk/clang-tidy/modernize/UseBoolLiteralsCheck.cpp
===
--- clang-tools-extra/trunk/clang-tidy/modernize/UseBoolLiteralsCheck.cpp
+++ clang-tools-extra/trunk/clang-tidy/modernize/UseBoolLiteralsCheck.cpp
@@ -29,6 +29,17 @@
   unless(isInTemplateInstantiation()),
   anyOf(hasParent(explicitCastExpr().bind("cast")), anything())),
   this);
+
+  Finder->addMatcher(
+  conditionalOperator(
+  hasParent(implicitCastExpr(
+  hasImplicitDestinationType(qualType(booleanType())),
+  unless(isInTemplateInstantiation(,
+  eachOf(hasTrueExpression(
+ ignoringParenImpCasts(integerLiteral().bind("literal"))),
+ hasFalseExpression(
+ ignoringParenImpCasts(integerLiteral().bind("literal"),
+  this);
 }
 
 void UseBoolLiteralsCheck::check(const MatchFinder::MatchResult ) {
Index: clang-tools-extra/trunk/docs/clang-tidy/checks/modernize-use-bool-literals.rst
===
--- clang-tools-extra/trunk/docs/clang-tidy/checks/modernize-use-bool-literals.rst
+++ clang-tools-extra/trunk/docs/clang-tidy/checks/modernize-use-bool-literals.rst
@@ -10,9 +10,11 @@
   bool p = 1;
   bool f = static_cast(1);
   std::ios_base::sync_with_stdio(0);
+  bool x = p ? 1 : 0;
 
   // transforms to
 
   bool p = true;
   bool f = true;
   std::ios_base::sync_with_stdio(false);
+  bool x = p ? true : false;
Index: clang-tools-extra/trunk/test/clang-tidy/modernize-use-bool-literals.cpp
===
--- clang-tools-extra/trunk/test/clang-tidy/modernize-use-bool-literals.cpp
+++ clang-tools-extra/trunk/test/clang-tidy/modernize-use-bool-literals.cpp
@@ -5,39 +5,39 @@
 // CHECK-FIXES: {{^}}bool IntToTrue = true;{{$}}
 
 bool IntToFalse(0);
-// CHECK-MESSAGES: :[[@LINE-1]]:17: warning: {{.*}}
+// CHECK-MESSAGES: :[[@LINE-1]]:17: warning: converting integer literal to bool
 // CHECK-FIXES: {{^}}bool IntToFalse(false);{{$}}
 
 bool LongLongToTrue{0x1LL};
-// CHECK-MESSAGES: :[[@LINE-1]]:21: warning: {{.*}}
+// CHECK-MESSAGES: :[[@LINE-1]]:21: warning: converting integer literal to bool
 // CHECK-FIXES: {{^}}bool LongLongToTrue{true};{{$}}
 
 bool ExplicitCStyleIntToFalse = (bool)0;
-// CHECK-MESSAGES: :[[@LINE-1]]:33: warning: {{.*}}
+// CHECK-MESSAGES: :[[@LINE-1]]:33: warning: converting integer literal to bool
 // CHECK-FIXES: {{^}}bool ExplicitCStyleIntToFalse = false;{{$}}
 
 bool ExplicitFunctionalIntToFalse = bool(0);
-// CHECK-MESSAGES: :[[@LINE-1]]:37: warning: {{.*}}
+// CHECK-MESSAGES: :[[@LINE-1]]:37: warning: converting integer literal to bool
 // CHECK-FIXES: {{^}}bool ExplicitFunctionalIntToFalse = false;{{$}}
 
 bool ExplicitStaticIntToFalse = static_cast(0);
-// CHECK-MESSAGES: :[[@LINE-1]]:33: warning: {{.*}}
+// CHECK-MESSAGES: :[[@LINE-1]]:33: warning: converting integer literal to bool
 // CHECK-FIXES: {{^}}bool ExplicitStaticIntToFalse = false;{{$}}
 
 #define TRUE_MACRO 1
 // CHECK-FIXES: {{^}}#define TRUE_MACRO 1{{$}}
 
 bool MacroIntToTrue = TRUE_MACRO;
-// CHECK-MESSAGES: :[[@LINE-1]]:23: warning: converting integer literal to bool, use bool literal instead [modernize-use-bool-literals]
+// CHECK-MESSAGES: :[[@LINE-1]]:23: warning: converting integer literal to bool
 // CHECK-FIXES: {{^}}bool MacroIntToTrue = TRUE_MACRO;{{$}}
 
 #define FALSE_MACRO bool(0)
 // CHECK-FIXES: {{^}}#define FALSE_MACRO bool(0){{$}}
 
 bool TrueBool = true; // OK
 
 bool FalseBool = bool(FALSE_MACRO);
-// CHECK-MESSAGES: :[[@LINE-1]]:23: warning: {{.*}}
+// CHECK-MESSAGES: :[[@LINE-1]]:23: warning: converting integer literal to bool
 // CHECK-FIXES: {{^}}bool FalseBool = bool(FALSE_MACRO);{{$}}
 
 void boolFunction(bool bar) {
@@ -52,28 +52,28 @@
 // CHECK-FIXES: {{^}}#define MACRO_DEPENDENT_CAST(x) static_cast(x){{$}}
 
 bool MacroDependentBool = MACRO_DEPENDENT_CAST(0);
-// CHECK-MESSAGES: :[[@LINE-1]]:27: warning: {{.*}}
+// CHECK-MESSAGES: :[[@LINE-1]]:27: warning: converting integer literal to bool
 // CHECK-FIXES: {{^}}bool MacroDependentBool = MACRO_DEPENDENT_CAST(0);{{$}}
 
 bool ManyMacrosDependent = MACRO_DEPENDENT_CAST(FALSE_MACRO);
-// CHECK-MESSAGES: :[[@LINE-1]]:49: warning: {{.*}}
+// CHECK-MESSAGES: :[[@LINE-1]]:49: warning: converting integer 

[clang-tools-extra] r278022 - [clang-tidy] enhance modernize-use-bool-literals to check ternary operator

2016-08-08 Thread Kirill Bobyrev via cfe-commits
Author: omtcyfz
Date: Mon Aug  8 12:11:56 2016
New Revision: 278022

URL: http://llvm.org/viewvc/llvm-project?rev=278022=rev
Log:
[clang-tidy] enhance modernize-use-bool-literals to check ternary operator

modernize-use-bool-literals doesn't checks operands in ternary operator.

For example:

``` c++
static int Value = 1;

bool foo() {
  bool Result = Value == 1 ? 1 : 0;
  return Result;
}

bool boo() {
  return Value == 1 ? 1 : 0;
}
```

This issue was reported in bug 28854. The patch fixes it.

Reviewers: alexfh, aaron.ballman, Prazek

Subscribers: Prazek, Eugene.Zelenko

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

Modified:
clang-tools-extra/trunk/clang-tidy/modernize/UseBoolLiteralsCheck.cpp

clang-tools-extra/trunk/docs/clang-tidy/checks/modernize-use-bool-literals.rst
clang-tools-extra/trunk/test/clang-tidy/modernize-use-bool-literals.cpp

Modified: clang-tools-extra/trunk/clang-tidy/modernize/UseBoolLiteralsCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/modernize/UseBoolLiteralsCheck.cpp?rev=278022=278021=278022=diff
==
--- clang-tools-extra/trunk/clang-tidy/modernize/UseBoolLiteralsCheck.cpp 
(original)
+++ clang-tools-extra/trunk/clang-tidy/modernize/UseBoolLiteralsCheck.cpp Mon 
Aug  8 12:11:56 2016
@@ -29,6 +29,17 @@ void UseBoolLiteralsCheck::registerMatch
   unless(isInTemplateInstantiation()),
   anyOf(hasParent(explicitCastExpr().bind("cast")), anything())),
   this);
+
+  Finder->addMatcher(
+  conditionalOperator(
+  hasParent(implicitCastExpr(
+  hasImplicitDestinationType(qualType(booleanType())),
+  unless(isInTemplateInstantiation(,
+  eachOf(hasTrueExpression(
+ ignoringParenImpCasts(integerLiteral().bind("literal"))),
+ hasFalseExpression(
+ 
ignoringParenImpCasts(integerLiteral().bind("literal"),
+  this);
 }
 
 void UseBoolLiteralsCheck::check(const MatchFinder::MatchResult ) {

Modified: 
clang-tools-extra/trunk/docs/clang-tidy/checks/modernize-use-bool-literals.rst
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/docs/clang-tidy/checks/modernize-use-bool-literals.rst?rev=278022=278021=278022=diff
==
--- 
clang-tools-extra/trunk/docs/clang-tidy/checks/modernize-use-bool-literals.rst 
(original)
+++ 
clang-tools-extra/trunk/docs/clang-tidy/checks/modernize-use-bool-literals.rst 
Mon Aug  8 12:11:56 2016
@@ -10,9 +10,11 @@ Finds integer literals which are cast to
   bool p = 1;
   bool f = static_cast(1);
   std::ios_base::sync_with_stdio(0);
+  bool x = p ? 1 : 0;
 
   // transforms to
 
   bool p = true;
   bool f = true;
   std::ios_base::sync_with_stdio(false);
+  bool x = p ? true : false;

Modified: 
clang-tools-extra/trunk/test/clang-tidy/modernize-use-bool-literals.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/modernize-use-bool-literals.cpp?rev=278022=278021=278022=diff
==
--- clang-tools-extra/trunk/test/clang-tidy/modernize-use-bool-literals.cpp 
(original)
+++ clang-tools-extra/trunk/test/clang-tidy/modernize-use-bool-literals.cpp Mon 
Aug  8 12:11:56 2016
@@ -5,30 +5,30 @@ bool IntToTrue = 1;
 // CHECK-FIXES: {{^}}bool IntToTrue = true;{{$}}
 
 bool IntToFalse(0);
-// CHECK-MESSAGES: :[[@LINE-1]]:17: warning: {{.*}}
+// CHECK-MESSAGES: :[[@LINE-1]]:17: warning: converting integer literal to bool
 // CHECK-FIXES: {{^}}bool IntToFalse(false);{{$}}
 
 bool LongLongToTrue{0x1LL};
-// CHECK-MESSAGES: :[[@LINE-1]]:21: warning: {{.*}}
+// CHECK-MESSAGES: :[[@LINE-1]]:21: warning: converting integer literal to bool
 // CHECK-FIXES: {{^}}bool LongLongToTrue{true};{{$}}
 
 bool ExplicitCStyleIntToFalse = (bool)0;
-// CHECK-MESSAGES: :[[@LINE-1]]:33: warning: {{.*}}
+// CHECK-MESSAGES: :[[@LINE-1]]:33: warning: converting integer literal to bool
 // CHECK-FIXES: {{^}}bool ExplicitCStyleIntToFalse = false;{{$}}
 
 bool ExplicitFunctionalIntToFalse = bool(0);
-// CHECK-MESSAGES: :[[@LINE-1]]:37: warning: {{.*}}
+// CHECK-MESSAGES: :[[@LINE-1]]:37: warning: converting integer literal to bool
 // CHECK-FIXES: {{^}}bool ExplicitFunctionalIntToFalse = false;{{$}}
 
 bool ExplicitStaticIntToFalse = static_cast(0);
-// CHECK-MESSAGES: :[[@LINE-1]]:33: warning: {{.*}}
+// CHECK-MESSAGES: :[[@LINE-1]]:33: warning: converting integer literal to bool
 // CHECK-FIXES: {{^}}bool ExplicitStaticIntToFalse = false;{{$}}
 
 #define TRUE_MACRO 1
 // CHECK-FIXES: {{^}}#define TRUE_MACRO 1{{$}}
 
 bool MacroIntToTrue = TRUE_MACRO;
-// CHECK-MESSAGES: :[[@LINE-1]]:23: warning: converting integer literal to 
bool, use bool literal instead [modernize-use-bool-literals]
+// CHECK-MESSAGES: :[[@LINE-1]]:23: warning: converting 

Re: [PATCH] D23243: [clang-tidy] enhance modernize-use-bool-literals to check ternary operator

2016-08-08 Thread Kirill Bobyrev via cfe-commits
omtcyfz marked an inline comment as done.
omtcyfz added a comment.

https://reviews.llvm.org/D23243



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


Re: [PATCH] D23257: Fix clang-tidy crash when a single fix is applied on multiple files.

2016-08-08 Thread Eric Liu via cfe-commits
ioeric updated this revision to Diff 67193.
ioeric marked 2 inline comments as done.
ioeric added a comment.

- Update test to not use 


https://reviews.llvm.org/D23257

Files:
  clang-tidy/ClangTidy.cpp
  clang-tidy/ClangTidyDiagnosticConsumer.cpp
  clang-tidy/ClangTidyDiagnosticConsumer.h
  test/clang-tidy/Inputs/modernize-pass-by-value/header-with-fix.h
  test/clang-tidy/modernize-pass-by-value-multi-fixes.cpp
  unittests/clang-tidy/ClangTidyTest.h

Index: unittests/clang-tidy/ClangTidyTest.h
===
--- unittests/clang-tidy/ClangTidyTest.h
+++ unittests/clang-tidy/ClangTidyTest.h
@@ -119,14 +119,15 @@
   DiagConsumer.finish();
   tooling::Replacements Fixes;
   for (const ClangTidyError  : Context.getErrors())
-for (const auto  : Error.Fix) {
-  auto Err = Fixes.add(Fix);
-  // FIXME: better error handling. Keep the behavior for now.
-  if (Err) {
-llvm::errs() << llvm::toString(std::move(Err)) << "\n";
-return "";
+for (const auto  : Error.Fix)
+  for (const auto  : FileAndFixes.second) {
+auto Err = Fixes.add(Fix);
+// FIXME: better error handling. Keep the behavior for now.
+if (Err) {
+  llvm::errs() << llvm::toString(std::move(Err)) << "\n";
+  return "";
+}
   }
-}
   if (Errors)
 *Errors = Context.getErrors();
   auto Result = tooling::applyAllReplacements(Code, Fixes);
Index: test/clang-tidy/modernize-pass-by-value-multi-fixes.cpp
===
--- /dev/null
+++ test/clang-tidy/modernize-pass-by-value-multi-fixes.cpp
@@ -0,0 +1,12 @@
+// RUN: cat %S/Inputs/modernize-pass-by-value/header-with-fix.h > %T/pass-by-value-header-with-fix.h
+// RUN: sed -e 's#//.*$##' %s > %t.cpp
+// RUN: clang-tidy %t.cpp -checks='-*,modernize-pass-by-value' -header-filter='.*' -fix -- -std=c++11 -I %T | FileCheck %s -check-prefix=CHECK-MESSAGES -implicit-check-not="{{warning|error}}:"
+// RUN: FileCheck -input-file=%t.cpp %s -check-prefix=CHECK-FIXES
+// RUN: FileCheck -input-file=%T/pass-by-value-header-with-fix.h %s -check-prefix=CHECK-HEADER-FIXES
+
+#include "pass-by-value-header-with-fix.h"
+// CHECK-HEADER-FIXES: Foo(S s);
+Foo::Foo(const S ) : s(s) {}
+// CHECK-MESSAGES: :9:10: warning: pass by value and use std::move [modernize-pass-by-value]
+// CHECK-FIXES: #include 
+// CHECK-FIXES: Foo::Foo(S s) : s(std::move(s)) {}
Index: test/clang-tidy/Inputs/modernize-pass-by-value/header-with-fix.h
===
--- /dev/null
+++ test/clang-tidy/Inputs/modernize-pass-by-value/header-with-fix.h
@@ -0,0 +1,8 @@
+struct S {
+  S(S&&);
+  S(const S&);
+};
+struct Foo {
+  Foo(const S );
+  S s;
+};
Index: clang-tidy/ClangTidyDiagnosticConsumer.h
===
--- clang-tidy/ClangTidyDiagnosticConsumer.h
+++ clang-tidy/ClangTidyDiagnosticConsumer.h
@@ -62,7 +62,8 @@
 
   std::string CheckName;
   ClangTidyMessage Message;
-  tooling::Replacements Fix;
+  // Fixes grouped by file path.
+  llvm::StringMap Fix;
   SmallVector Notes;
 
   // A build directory of the diagnostic source file.
Index: clang-tidy/ClangTidyDiagnosticConsumer.cpp
===
--- clang-tidy/ClangTidyDiagnosticConsumer.cpp
+++ clang-tidy/ClangTidyDiagnosticConsumer.cpp
@@ -77,8 +77,8 @@
   assert(Range.getBegin().isFileID() && Range.getEnd().isFileID() &&
  "Only file locations supported in fix-it hints.");
 
-  auto Err =
-  Error.Fix.add(tooling::Replacement(SM, Range, FixIt.CodeToInsert));
+  tooling::Replacement Replacement(SM, Range, FixIt.CodeToInsert);
+  auto Err = Error.Fix[Replacement.getFilePath()].add(Replacement);
   // FIXME: better error handling.
   if (Err) {
 llvm::errs() << "Fix conflicts with existing fix! "
@@ -495,27 +495,28 @@
   std::vector Sizes;
   for (const auto  : Errors) {
 int Size = 0;
-for (const auto  : Error.Fix)
-  Size += Replace.getLength();
+for (const auto  : Error.Fix)
+  for (const auto  : FileAndReplaces.second)
+Size += Replace.getLength();
 Sizes.push_back(Size);
   }
 
   // Build events from error intervals.
   std::map FileEvents;
-  for (unsigned I = 0; I < Errors.size(); ++I) {
-for (const auto  : Errors[I].Fix) {
-  unsigned Begin = Replace.getOffset();
-  unsigned End = Begin + Replace.getLength();
-  const std::string  = Replace.getFilePath();
-  // FIXME: Handle empty intervals, such as those from insertions.
-  if (Begin == End)
-continue;
-  FileEvents[FilePath].push_back(
-  Event(Begin, End, Event::ET_Begin, I, Sizes[I]));
-  FileEvents[FilePath].push_back(
-  Event(Begin, End, Event::ET_End, I, Sizes[I]));
-}
-  }
+  for (unsigned I 

Re: [PATCH] D23243: [clang-tidy] enhance modernize-use-bool-literals to check ternary operator

2016-08-08 Thread Alexander Kornienko via cfe-commits
alexfh accepted this revision.
alexfh added a comment.
This revision is now accepted and ready to land.

LG with a nit.



Comment at: test/clang-tidy/modernize-use-bool-literals.cpp:124
@@ +123,3 @@
+  bool Result = Value == 1 ? 1 : 0;
+  // CHECK-MESSAGES: :[[@LINE-1]]:30: {{.*}}
+  // CHECK-MESSAGES: :[[@LINE-2]]:34: {{.*}}

The check lines should be a bit stricter. Please change to  `:[[@LINE-1]]:30: 
warning: converting integer literal to bool`. Other new patterns in this file 
as well.


https://reviews.llvm.org/D23243



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


Re: [PATCH] D23274: Add an option to clang-format to remove duplicate headers.

2016-08-08 Thread Eric Liu via cfe-commits
ioeric updated this revision to Diff 67191.
ioeric added a comment.

- Check code that is not in affected range is not reformatted in lit test.


https://reviews.llvm.org/D23274

Files:
  include/clang/Format/Format.h
  lib/Format/Format.cpp
  test/Format/remove-duplicate-includes.cpp
  tools/clang-format/ClangFormat.cpp
  unittests/Format/SortIncludesTest.cpp

Index: unittests/Format/SortIncludesTest.cpp
===
--- unittests/Format/SortIncludesTest.cpp
+++ unittests/Format/SortIncludesTest.cpp
@@ -26,8 +26,9 @@
 
   std::string sort(StringRef Code, StringRef FileName = "input.cpp") {
 auto Ranges = GetCodeRange(Code);
-auto Sorted =
-applyAllReplacements(Code, sortIncludes(Style, Code, Ranges, FileName));
+auto Replaces = sortIncludes(Style, Code, Ranges, FileName);
+Ranges = tooling::calculateRangesAfterReplacements(Replaces, Ranges);
+auto Sorted = applyAllReplacements(Code, Replaces);
 EXPECT_TRUE(static_cast(Sorted));
 auto Result = applyAllReplacements(
 *Sorted, reformat(Style, *Sorted, Ranges, FileName));
@@ -286,6 +287,87 @@
   EXPECT_EQ(10u, newCursor(Code, 43));
 }
 
+TEST_F(SortIncludesTest, DeduplicateIncludes) {
+  Style.DeduplicateIncludes = true;
+  EXPECT_EQ("#include \n"
+"#include \n"
+"#include \n",
+sort("#include \n"
+ "#include \n"
+ "#include \n"
+ "#include \n"
+ "#include \n"
+ "#include \n"));
+}
+
+TEST_F(SortIncludesTest, SortAndDeduplicateIncludes) {
+  Style.DeduplicateIncludes = true;
+  EXPECT_EQ("#include \n"
+"#include \n"
+"#include \n",
+sort("#include \n"
+ "#include \n"
+ "#include \n"
+ "#include \n"
+ "#include \n"
+ "#include \n"));
+}
+
+TEST_F(SortIncludesTest, CalculatesCorrectCursorPositionAfterDeduplicate) {
+  Style.DeduplicateIncludes = true;
+  std::string Code = "#include \n"  // Start of line: 0
+ "#include \n"  // Start of line: 13
+ "#include \n"  // Start of line: 26
+ "#include \n"  // Start of line: 39
+ "#include \n"  // Start of line: 52
+ "#include \n"; // Start of line: 65
+  std::string Expected = "#include \n"  // Start of line: 0
+ "#include \n"  // Start of line: 13
+ "#include \n"; // Start of line: 26
+  EXPECT_EQ(Expected, sort(Code));
+  // Cursor on 'i' in "#include ".
+  EXPECT_EQ(1u, newCursor(Code, 14));
+  // Cursor on 'b' in "#include ".
+  EXPECT_EQ(23u, newCursor(Code, 10));
+  EXPECT_EQ(23u, newCursor(Code, 36));
+  EXPECT_EQ(23u, newCursor(Code, 49));
+  EXPECT_EQ(23u, newCursor(Code, 36));
+  EXPECT_EQ(23u, newCursor(Code, 75));
+  // Cursor on '#' in "#include ".
+  EXPECT_EQ(26u, newCursor(Code, 52));
+}
+
+TEST_F(SortIncludesTest, DeduplicateLocallyInEachBlock) {
+  Style.DeduplicateIncludes = true;
+  EXPECT_EQ("#include \n"
+"#include \n"
+"\n"
+"#include \n"
+"#include \n",
+sort("#include \n"
+ "#include \n"
+ "\n"
+ "#include \n"
+ "#include \n"
+ "#include \n"));
+}
+
+TEST_F(SortIncludesTest, ValidAffactedRangesAfterDeduplicatingIncludes) {
+  Style.DeduplicateIncludes = true;
+  std::string Code = "#include \n"
+ "#include \n"
+ "#include \n"
+ "#include \n"
+ "\n"
+ "   int x ;";
+  std::vector Ranges = {tooling::Range(0, 52)};
+  auto Replaces = sortIncludes(Style, Code, Ranges, "input.cpp");
+  Ranges = tooling::calculateRangesAfterReplacements(Replaces, Ranges);
+  EXPECT_EQ(1u, Ranges.size());
+  EXPECT_EQ(0u, Ranges[0].getOffset());
+  EXPECT_EQ(26u, Ranges[0].getLength());
+}
+
 } // end namespace
 } // end namespace format
 } // end namespace clang
Index: tools/clang-format/ClangFormat.cpp
===
--- tools/clang-format/ClangFormat.cpp
+++ tools/clang-format/ClangFormat.cpp
@@ -260,9 +260,8 @@
 llvm::errs() << llvm::toString(ChangedCode.takeError()) << "\n";
 return true;
   }
-  for (const auto  : Replaces)
-Ranges.push_back({R.getOffset(), R.getLength()});
-
+  // Get new affected ranges after sorting `#includes`.
+  Ranges = tooling::calculateRangesAfterReplacements(Replaces, Ranges);
   bool IncompleteFormat = false;
   Replacements FormatChanges = reformat(FormatStyle, *ChangedCode, Ranges,
 AssumedFileName, );
Index: test/Format/remove-duplicate-includes.cpp
===
--- /dev/null
+++ 

Re: [PATCH] D23243: [clang-tidy] enhance modernize-use-bool-literals to check ternary operator

2016-08-08 Thread Kirill Bobyrev via cfe-commits
omtcyfz updated this revision to Diff 67189.
omtcyfz added a comment.

Remove redundant `anyOf` and `anything`.


https://reviews.llvm.org/D23243

Files:
  clang-tidy/modernize/UseBoolLiteralsCheck.cpp
  docs/clang-tidy/checks/modernize-use-bool-literals.rst
  test/clang-tidy/modernize-use-bool-literals.cpp

Index: test/clang-tidy/modernize-use-bool-literals.cpp
===
--- test/clang-tidy/modernize-use-bool-literals.cpp
+++ test/clang-tidy/modernize-use-bool-literals.cpp
@@ -116,3 +116,33 @@
   // CHECK-MESSAGES: :[[@LINE-1]]:15: warning: {{.*}}
   // CHECK-FIXES: {{^ *}}IntToTrue = true;{{$}}
 }
+
+static int Value = 1;
+
+bool Function1() {
+  bool Result = Value == 1 ? 1 : 0;
+  // CHECK-MESSAGES: :[[@LINE-1]]:30: {{.*}}
+  // CHECK-MESSAGES: :[[@LINE-2]]:34: {{.*}}
+  // CHECK-FIXES: {{^ *}}bool Result = Value == 1 ? true : false;{{$}}
+  return Result;
+}
+
+bool Function2() {
+  return Value == 1 ? 1 : 0;
+  // CHECK-MESSAGES: :[[@LINE-1]]:23: {{.*}}
+  // CHECK-MESSAGES: :[[@LINE-2]]:27: {{.*}}
+  // CHECK-FIXES: {{^ *}}return Value == 1 ? true : false;{{$}}
+}
+
+void foo() {
+  bool Result;
+  Result = Value == 1 ? true : 0;
+  // CHECK-MESSAGES: :[[@LINE-1]]:32: {{.*}}
+  // CHECK-FIXES: {{^ *}}Result = Value == 1 ? true : false;{{$}}
+  Result = Value == 1 ? false : bool(0);
+  // CHECK-MESSAGES: :[[@LINE-1]]:33: {{.*}}
+  // CHECK-FIXES: {{^ *}}Result = Value == 1 ? false : false;{{$}}
+  Result = Value == 1 ? (bool)0 : false;
+  // CHECK-MESSAGES: :[[@LINE-1]]:25: {{.*}}
+  // CHECK-FIXES: {{^ *}}Result = Value == 1 ? false : false;{{$}}
+}
Index: docs/clang-tidy/checks/modernize-use-bool-literals.rst
===
--- docs/clang-tidy/checks/modernize-use-bool-literals.rst
+++ docs/clang-tidy/checks/modernize-use-bool-literals.rst
@@ -10,9 +10,11 @@
   bool p = 1;
   bool f = static_cast(1);
   std::ios_base::sync_with_stdio(0);
+  bool x = p ? 1 : 0;
 
   // transforms to
 
   bool p = true;
   bool f = true;
   std::ios_base::sync_with_stdio(false);
+  bool x = p ? true : false;
Index: clang-tidy/modernize/UseBoolLiteralsCheck.cpp
===
--- clang-tidy/modernize/UseBoolLiteralsCheck.cpp
+++ clang-tidy/modernize/UseBoolLiteralsCheck.cpp
@@ -29,6 +29,17 @@
   unless(isInTemplateInstantiation()),
   anyOf(hasParent(explicitCastExpr().bind("cast")), anything())),
   this);
+
+  Finder->addMatcher(
+  conditionalOperator(
+  hasParent(implicitCastExpr(
+  hasImplicitDestinationType(qualType(booleanType())),
+  unless(isInTemplateInstantiation(,
+  eachOf(hasTrueExpression(
+ ignoringParenImpCasts(integerLiteral().bind("literal"))),
+ hasFalseExpression(
+ 
ignoringParenImpCasts(integerLiteral().bind("literal"),
+  this);
 }
 
 void UseBoolLiteralsCheck::check(const MatchFinder::MatchResult ) {


Index: test/clang-tidy/modernize-use-bool-literals.cpp
===
--- test/clang-tidy/modernize-use-bool-literals.cpp
+++ test/clang-tidy/modernize-use-bool-literals.cpp
@@ -116,3 +116,33 @@
   // CHECK-MESSAGES: :[[@LINE-1]]:15: warning: {{.*}}
   // CHECK-FIXES: {{^ *}}IntToTrue = true;{{$}}
 }
+
+static int Value = 1;
+
+bool Function1() {
+  bool Result = Value == 1 ? 1 : 0;
+  // CHECK-MESSAGES: :[[@LINE-1]]:30: {{.*}}
+  // CHECK-MESSAGES: :[[@LINE-2]]:34: {{.*}}
+  // CHECK-FIXES: {{^ *}}bool Result = Value == 1 ? true : false;{{$}}
+  return Result;
+}
+
+bool Function2() {
+  return Value == 1 ? 1 : 0;
+  // CHECK-MESSAGES: :[[@LINE-1]]:23: {{.*}}
+  // CHECK-MESSAGES: :[[@LINE-2]]:27: {{.*}}
+  // CHECK-FIXES: {{^ *}}return Value == 1 ? true : false;{{$}}
+}
+
+void foo() {
+  bool Result;
+  Result = Value == 1 ? true : 0;
+  // CHECK-MESSAGES: :[[@LINE-1]]:32: {{.*}}
+  // CHECK-FIXES: {{^ *}}Result = Value == 1 ? true : false;{{$}}
+  Result = Value == 1 ? false : bool(0);
+  // CHECK-MESSAGES: :[[@LINE-1]]:33: {{.*}}
+  // CHECK-FIXES: {{^ *}}Result = Value == 1 ? false : false;{{$}}
+  Result = Value == 1 ? (bool)0 : false;
+  // CHECK-MESSAGES: :[[@LINE-1]]:25: {{.*}}
+  // CHECK-FIXES: {{^ *}}Result = Value == 1 ? false : false;{{$}}
+}
Index: docs/clang-tidy/checks/modernize-use-bool-literals.rst
===
--- docs/clang-tidy/checks/modernize-use-bool-literals.rst
+++ docs/clang-tidy/checks/modernize-use-bool-literals.rst
@@ -10,9 +10,11 @@
   bool p = 1;
   bool f = static_cast(1);
   std::ios_base::sync_with_stdio(0);
+  bool x = p ? 1 : 0;
 
   // transforms to
 
   bool p = true;
   bool f = true;
   std::ios_base::sync_with_stdio(false);
+  bool x = p ? true : false;
Index: clang-tidy/modernize/UseBoolLiteralsCheck.cpp

Re: [PATCH] D23243: [clang-tidy] enhance modernize-use-bool-literals to check ternary operator

2016-08-08 Thread Kirill Bobyrev via cfe-commits
omtcyfz marked an inline comment as done.
omtcyfz added a comment.

https://reviews.llvm.org/D23243



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


[PATCH] D23274: Add an option to clang-format to remove duplicate headers.

2016-08-08 Thread Eric Liu via cfe-commits
ioeric created this revision.
ioeric added a reviewer: djasper.
ioeric added a subscriber: cfe-commits.
Herald added a subscriber: klimek.

https://reviews.llvm.org/D23274

Files:
  include/clang/Format/Format.h
  lib/Format/Format.cpp
  test/Format/remove-duplicate-includes.cpp
  tools/clang-format/ClangFormat.cpp
  unittests/Format/SortIncludesTest.cpp

Index: unittests/Format/SortIncludesTest.cpp
===
--- unittests/Format/SortIncludesTest.cpp
+++ unittests/Format/SortIncludesTest.cpp
@@ -26,8 +26,9 @@
 
   std::string sort(StringRef Code, StringRef FileName = "input.cpp") {
 auto Ranges = GetCodeRange(Code);
-auto Sorted =
-applyAllReplacements(Code, sortIncludes(Style, Code, Ranges, FileName));
+auto Replaces = sortIncludes(Style, Code, Ranges, FileName);
+Ranges = tooling::calculateRangesAfterReplacements(Replaces, Ranges);
+auto Sorted = applyAllReplacements(Code, Replaces);
 EXPECT_TRUE(static_cast(Sorted));
 auto Result = applyAllReplacements(
 *Sorted, reformat(Style, *Sorted, Ranges, FileName));
@@ -286,6 +287,87 @@
   EXPECT_EQ(10u, newCursor(Code, 43));
 }
 
+TEST_F(SortIncludesTest, DeduplicateIncludes) {
+  Style.DeduplicateIncludes = true;
+  EXPECT_EQ("#include \n"
+"#include \n"
+"#include \n",
+sort("#include \n"
+ "#include \n"
+ "#include \n"
+ "#include \n"
+ "#include \n"
+ "#include \n"));
+}
+
+TEST_F(SortIncludesTest, SortAndDeduplicateIncludes) {
+  Style.DeduplicateIncludes = true;
+  EXPECT_EQ("#include \n"
+"#include \n"
+"#include \n",
+sort("#include \n"
+ "#include \n"
+ "#include \n"
+ "#include \n"
+ "#include \n"
+ "#include \n"));
+}
+
+TEST_F(SortIncludesTest, CalculatesCorrectCursorPositionAfterDeduplicate) {
+  Style.DeduplicateIncludes = true;
+  std::string Code = "#include \n"  // Start of line: 0
+ "#include \n"  // Start of line: 13
+ "#include \n"  // Start of line: 26
+ "#include \n"  // Start of line: 39
+ "#include \n"  // Start of line: 52
+ "#include \n"; // Start of line: 65
+  std::string Expected = "#include \n"  // Start of line: 0
+ "#include \n"  // Start of line: 13
+ "#include \n"; // Start of line: 26
+  EXPECT_EQ(Expected, sort(Code));
+  // Cursor on 'i' in "#include ".
+  EXPECT_EQ(1u, newCursor(Code, 14));
+  // Cursor on 'b' in "#include ".
+  EXPECT_EQ(23u, newCursor(Code, 10));
+  EXPECT_EQ(23u, newCursor(Code, 36));
+  EXPECT_EQ(23u, newCursor(Code, 49));
+  EXPECT_EQ(23u, newCursor(Code, 36));
+  EXPECT_EQ(23u, newCursor(Code, 75));
+  // Cursor on '#' in "#include ".
+  EXPECT_EQ(26u, newCursor(Code, 52));
+}
+
+TEST_F(SortIncludesTest, DeduplicateLocallyInEachBlock) {
+  Style.DeduplicateIncludes = true;
+  EXPECT_EQ("#include \n"
+"#include \n"
+"\n"
+"#include \n"
+"#include \n",
+sort("#include \n"
+ "#include \n"
+ "\n"
+ "#include \n"
+ "#include \n"
+ "#include \n"));
+}
+
+TEST_F(SortIncludesTest, ValidAffactedRangesAfterDeduplicatingIncludes) {
+  Style.DeduplicateIncludes = true;
+  std::string Code = "#include \n"
+ "#include \n"
+ "#include \n"
+ "#include \n"
+ "\n"
+ "   int x ;";
+  std::vector Ranges = {tooling::Range(0, 52)};
+  auto Replaces = sortIncludes(Style, Code, Ranges, "input.cpp");
+  Ranges = tooling::calculateRangesAfterReplacements(Replaces, Ranges);
+  EXPECT_EQ(1u, Ranges.size());
+  EXPECT_EQ(0u, Ranges[0].getOffset());
+  EXPECT_EQ(26u, Ranges[0].getLength());
+}
+
 } // end namespace
 } // end namespace format
 } // end namespace clang
Index: tools/clang-format/ClangFormat.cpp
===
--- tools/clang-format/ClangFormat.cpp
+++ tools/clang-format/ClangFormat.cpp
@@ -260,9 +260,8 @@
 llvm::errs() << llvm::toString(ChangedCode.takeError()) << "\n";
 return true;
   }
-  for (const auto  : Replaces)
-Ranges.push_back({R.getOffset(), R.getLength()});
-
+  // Get new affected ranges after sorting `#includes`.
+  Ranges = tooling::calculateRangesAfterReplacements(Replaces, Ranges);
   bool IncompleteFormat = false;
   Replacements FormatChanges = reformat(FormatStyle, *ChangedCode, Ranges,
 AssumedFileName, );
Index: test/Format/remove-duplicate-includes.cpp
===
--- /dev/null
+++ 

RE: r277743 - [OpenCL] Added underscores to the names of 'to_addr' OpenCL built-ins.

2016-08-08 Thread Anastasia Stulova via cfe-commits
Thanks!

-Original Message-
From: hwennb...@google.com [mailto:hwennb...@google.com] On Behalf Of Hans 
Wennborg
Sent: 08 August 2016 17:40
To: Anastasia Stulova
Cc: Alexey Bader; cfe-commits@lists.llvm.org; nd
Subject: Re: r277743 - [OpenCL] Added underscores to the names of 'to_addr' 
OpenCL built-ins.

Okay, merged in r278019.

Cheers,
Hans

On Fri, Aug 5, 2016 at 9:36 AM, Anastasia Stulova  
wrote:
> Hans,
>
> If still possible could we merge this into 3.9. It contains just a minor 
> renaming but it makes all those new OpenCL Builtins usable.
>
> Thanks,
> Anastasia
>
> -Original Message-
> From: cfe-commits [mailto:cfe-commits-boun...@lists.llvm.org] On 
> Behalf Of Alexey Bader via cfe-commits
> Sent: 04 August 2016 19:06
> To: cfe-commits@lists.llvm.org
> Subject: r277743 - [OpenCL] Added underscores to the names of 'to_addr' 
> OpenCL built-ins.
>
> Author: bader
> Date: Thu Aug  4 13:06:27 2016
> New Revision: 277743
>
> URL: http://llvm.org/viewvc/llvm-project?rev=277743=rev
> Log:
> [OpenCL] Added underscores to the names of 'to_addr' OpenCL built-ins.
>
> Summary:
> In order to re-define OpenCL built-in functions 'to_{private,local,global}' 
> in OpenCL run-time library LLVM names must be different from the clang 
> built-in function names.
>
> Reviewers: yaxunl, Anastasia
>
> Subscribers: cfe-commits
>
> Differential Revision: https://reviews.llvm.org/D23120
>
> Modified:
> cfe/trunk/lib/CodeGen/CGBuiltin.cpp
> cfe/trunk/test/CodeGenOpenCL/to_addr_builtin.cl
>
> Modified: cfe/trunk/lib/CodeGen/CGBuiltin.cpp
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGBuiltin.cp
> p?rev=277743=277742=277743=diff
> ==
> 
> --- cfe/trunk/lib/CodeGen/CGBuiltin.cpp (original)
> +++ cfe/trunk/lib/CodeGen/CGBuiltin.cpp Thu Aug  4 13:06:27 2016
> @@ -2209,8 +2209,9 @@ RValue CodeGenFunction::EmitBuiltinExpr(
>NewArg = Builder.CreateAddrSpaceCast(Arg0, NewArgT);
>  else
>NewArg = Builder.CreateBitOrPointerCast(Arg0, NewArgT);
> -auto NewCall = Builder.CreateCall(CGM.CreateRuntimeFunction(FTy,
> -  E->getDirectCallee()->getName()), {NewArg});
> +auto NewName = std::string("__") + E->getDirectCallee()->getName().str();
> +auto NewCall =
> +Builder.CreateCall(CGM.CreateRuntimeFunction(FTy, NewName), 
> + {NewArg});
>  return RValue::get(Builder.CreateBitOrPointerCast(NewCall,
>ConvertType(E->getType(;
>}
>
> Modified: cfe/trunk/test/CodeGenOpenCL/to_addr_builtin.cl
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenOpenCL/to_ad
> dr_builtin.cl?rev=277743=277742=277743=diff
> ==
> 
> --- cfe/trunk/test/CodeGenOpenCL/to_addr_builtin.cl (original)
> +++ cfe/trunk/test/CodeGenOpenCL/to_addr_builtin.cl Thu Aug  4 
> +++ 13:06:27
> +++ 2016
> @@ -14,74 +14,74 @@ void test(void) {
>generic int *gen;
>
>//CHECK: %[[ARG:.*]] = addrspacecast i32 addrspace(1)* %{{.*}} to 
> i8 addrspace(4)*
> -  //CHECK: %[[RET:.*]] = call i8 addrspace(1)* @to_global(i8 
> addrspace(4)* %[[ARG]])
> +  //CHECK: %[[RET:.*]] = call i8 addrspace(1)* @__to_global(i8
> + addrspace(4)* %[[ARG]])
>//CHECK: %{{.*}} = bitcast i8 addrspace(1)* %[[RET]] to i32 addrspace(1)*
>glob = to_global(glob);
>
>//CHECK: %[[ARG:.*]] = addrspacecast i32 addrspace(3)* %{{.*}} to 
> i8 addrspace(4)*
> -  //CHECK: %[[RET:.*]] = call i8 addrspace(1)* @to_global(i8 
> addrspace(4)* %[[ARG]])
> +  //CHECK: %[[RET:.*]] = call i8 addrspace(1)* @__to_global(i8
> + addrspace(4)* %[[ARG]])
>//CHECK: %{{.*}} = bitcast i8 addrspace(1)* %[[RET]] to i32 addrspace(1)*
>glob = to_global(loc);
>
>//CHECK: %[[ARG:.*]] = addrspacecast i32* %{{.*}} to i8 
> addrspace(4)*
> -  //CHECK: %[[RET:.*]] = call i8 addrspace(1)* @to_global(i8 
> addrspace(4)* %[[ARG]])
> +  //CHECK: %[[RET:.*]] = call i8 addrspace(1)* @__to_global(i8
> + addrspace(4)* %[[ARG]])
>//CHECK: %{{.*}} = bitcast i8 addrspace(1)* %[[RET]] to i32 addrspace(1)*
>glob = to_global(priv);
>
>//CHECK: %[[ARG:.*]] = bitcast i32 addrspace(4)* %{{.*}} to i8 
> addrspace(4)*
> -  //CHECK: %[[RET:.*]] = call i8 addrspace(1)* @to_global(i8 
> addrspace(4)* %[[ARG]])
> +  //CHECK: %[[RET:.*]] = call i8 addrspace(1)* @__to_global(i8
> + addrspace(4)* %[[ARG]])
>//CHECK: %{{.*}} = bitcast i8 addrspace(1)* %[[RET]] to i32 addrspace(1)*
>glob = to_global(gen);
>
>//CHECK: %[[ARG:.*]] = addrspacecast i32 addrspace(1)* %{{.*}} to 
> i8 addrspace(4)*
> -  //CHECK: %[[RET:.*]] = call i8 addrspace(3)* @to_local(i8 
> addrspace(4)* %[[ARG]])
> +  //CHECK: %[[RET:.*]] = call i8 addrspace(3)* @__to_local(i8
> + addrspace(4)* %[[ARG]])
>//CHECK: %{{.*}} = bitcast i8 addrspace(3)* %[[RET]] to i32 addrspace(3)*
>loc = to_local(glob);
>
>//CHECK: %[[ARG:.*]] = addrspacecast i32 

r278018 - [analyzer] Change -analyze-function to accept qualified names.

2016-08-08 Thread Artem Dergachev via cfe-commits
Author: dergachev
Date: Mon Aug  8 11:01:02 2016
New Revision: 278018

URL: http://llvm.org/viewvc/llvm-project?rev=278018=rev
Log:
[analyzer] Change -analyze-function to accept qualified names.

Both -analyze-function and -analyzer-display-progress now share the same
convention for naming functions, which allows discriminating between
methods with the same name in different classes, C++ overloads, and also
presents Objective-C instance and class methods in the convenient notation.

This also allows looking up the name for the particular function you're trying
to restrict analysis to in the -analyzer-display-progress output,
in case it was not instantly obvious.

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

Added:
cfe/trunk/test/Analysis/analyzer-display-progress.cpp
cfe/trunk/test/Analysis/analyzer-display-progress.m
Removed:
cfe/trunk/test/Analysis/analyze_display_progress.cpp
Modified:
cfe/trunk/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp
cfe/trunk/test/Analysis/analyzeOneFunction.m

Modified: cfe/trunk/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp?rev=278018=278017=278018=diff
==
--- cfe/trunk/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp Mon Aug  8 
11:01:02 2016
@@ -265,19 +265,8 @@ public:
   else
 assert(Mode == (AM_Syntax | AM_Path) && "Unexpected mode!");
 
-  llvm::errs() << ": " << Loc.getFilename();
-  if (isa(D) || isa(D)) {
-const NamedDecl *ND = cast(D);
-llvm::errs() << ' ' << ND->getQualifiedNameAsString() << '\n';
-  }
-  else if (isa(D)) {
-llvm::errs() << ' ' << "block(line:" << Loc.getLine() << ",col:"
- << Loc.getColumn() << '\n';
-  }
-  else if (const ObjCMethodDecl *MD = dyn_cast(D)) {
-Selector S = MD->getSelector();
-llvm::errs() << ' ' << S.getAsString();
-  }
+  llvm::errs() << ": " << Loc.getFilename() << ' '
+   << getFunctionName(D) << '\n';
 }
   }
 
@@ -377,6 +366,7 @@ public:
 
 private:
   void storeTopLevelDecls(DeclGroupRef DG);
+  std::string getFunctionName(const Decl *D);
 
   /// \brief Check if we should skip (not analyze) the given function.
   AnalysisMode getModeForDecl(Decl *D, AnalysisMode Mode);
@@ -568,16 +558,64 @@ void AnalysisConsumer::HandleTranslation
 
 }
 
-static std::string getFunctionName(const Decl *D) {
-  if (const ObjCMethodDecl *ID = dyn_cast(D)) {
-return ID->getSelector().getAsString();
-  }
-  if (const FunctionDecl *ND = dyn_cast(D)) {
-IdentifierInfo *II = ND->getIdentifier();
-if (II)
-  return II->getName();
+std::string AnalysisConsumer::getFunctionName(const Decl *D) {
+  std::string Str;
+  llvm::raw_string_ostream OS(Str);
+
+  if (const FunctionDecl *FD = dyn_cast(D)) {
+OS << FD->getQualifiedNameAsString();
+
+// In C++, there are overloads.
+if (Ctx->getLangOpts().CPlusPlus) {
+  OS << '(';
+  for (const auto  : FD->parameters()) {
+if (P != *FD->param_begin())
+  OS << ", ";
+OS << P->getType().getAsString();
+  }
+  OS << ')';
+}
+
+  } else if (isa(D)) {
+PresumedLoc Loc = Ctx->getSourceManager().getPresumedLoc(D->getLocation());
+
+if (Loc.isValid()) {
+  OS << "block (line: " << Loc.getLine() << ", col: " << Loc.getColumn()
+ << ')';
+}
+
+  } else if (const ObjCMethodDecl *OMD = dyn_cast(D)) {
+
+// FIXME: copy-pasted from CGDebugInfo.cpp.
+OS << (OMD->isInstanceMethod() ? '-' : '+') << '[';
+const DeclContext *DC = OMD->getDeclContext();
+if (const auto *OID = dyn_cast(DC)) {
+  OS << OID->getName();
+} else if (const auto *OID = dyn_cast(DC)) {
+  OS << OID->getName();
+} else if (const auto *OC = dyn_cast(DC)) {
+  if (OC->IsClassExtension()) {
+OS << OC->getClassInterface()->getName();
+  } else {
+OS << OC->getIdentifier()->getNameStart() << '('
+   << OC->getIdentifier()->getNameStart() << ')';
+  }
+} else if (const auto *OCD = dyn_cast(DC)) {
+  OS << ((const NamedDecl *)OCD)->getIdentifier()->getNameStart() << '('
+ << OCD->getIdentifier()->getNameStart() << ')';
+} else if (isa(DC)) {
+  // We can extract the type of the class from the self pointer.
+  if (ImplicitParamDecl *SelfDecl = OMD->getSelfDecl()) {
+QualType ClassTy =
+cast(SelfDecl->getType())->getPointeeType();
+ClassTy.print(OS, PrintingPolicy(LangOptions()));
+  }
+}
+OS << ' ' << OMD->getSelector().getAsString() << ']';
+
   }
-  return "";
+
+  return OS.str();
 }
 
 AnalysisConsumer::AnalysisMode

Modified: cfe/trunk/test/Analysis/analyzeOneFunction.m
URL: 

Re: Diagnostics improvements for 3.9

2016-08-08 Thread Hans Wennborg via cfe-commits
I've merged the lot in r278020.

Thanks,
Hans

On Fri, Aug 5, 2016 at 7:43 PM, Hans Wennborg  wrote:
> These all sgtm for 3.9. Go ahead and merge with
> utils/release/merge.sh, or I'll do it when I get in on Monday.
>
> Cheers,
> Hans
>
> On Fri, Aug 5, 2016 at 6:52 PM, Richard Trieu  wrote:
>> Typos and unused test variables fixed in r277900
>>
>> On Fri, Aug 5, 2016 at 6:46 PM, Richard Smith  wrote:
>>>
>>> On Fri, Aug 5, 2016 at 6:33 PM, Richard Smith 
>>> wrote:

 These all look OK for the branch. Hans, the second one fixes a crasher,
 so I'd like to take at least that one. The others fix warning false
 positives (which are not regressions) and look fairly safe.
>>>
>>>
>>> Correction: looks like the final one is in fact a fix for a diagnostic
>>> regression.
>>>

 On Fri, Aug 5, 2016 at 4:39 PM, Richard Trieu  wrote:
>
> Hans, Richard,
>
> These are some last minute diagnostic improvements for 3.9.
>
> http://llvm.org/viewvc/llvm-project?rev=277796=rev
> r277796
> Don't warn when negative values, like -1, are used to initialize
> unsigned bit fields.
>
> http://llvm.org/viewvc/llvm-project?rev=277797=rev
> r277797
> Fix crash with type alias in Template Type Diffing


 (You have a typo Internalal in this.)

>
> http://llvm.org/viewvc/llvm-project?rev=277866=rev
> r277866
> Fix false positive in -Wunsequenced and templates
>
> http://llvm.org/viewvc/llvm-project?rev=277889=rev
> r277889
> Fixes for two false positives in -Wreturn-stack-address dealing with
> parameter variables and reference to pointer types.


 (Test has some x3 variables that are unused.)
>>>
>>>
>>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: r277743 - [OpenCL] Added underscores to the names of 'to_addr' OpenCL built-ins.

2016-08-08 Thread Hans Wennborg via cfe-commits
Okay, merged in r278019.

Cheers,
Hans

On Fri, Aug 5, 2016 at 9:36 AM, Anastasia Stulova
 wrote:
> Hans,
>
> If still possible could we merge this into 3.9. It contains just a minor 
> renaming but it makes all those new OpenCL Builtins usable.
>
> Thanks,
> Anastasia
>
> -Original Message-
> From: cfe-commits [mailto:cfe-commits-boun...@lists.llvm.org] On Behalf Of 
> Alexey Bader via cfe-commits
> Sent: 04 August 2016 19:06
> To: cfe-commits@lists.llvm.org
> Subject: r277743 - [OpenCL] Added underscores to the names of 'to_addr' 
> OpenCL built-ins.
>
> Author: bader
> Date: Thu Aug  4 13:06:27 2016
> New Revision: 277743
>
> URL: http://llvm.org/viewvc/llvm-project?rev=277743=rev
> Log:
> [OpenCL] Added underscores to the names of 'to_addr' OpenCL built-ins.
>
> Summary:
> In order to re-define OpenCL built-in functions 'to_{private,local,global}' 
> in OpenCL run-time library LLVM names must be different from the clang 
> built-in function names.
>
> Reviewers: yaxunl, Anastasia
>
> Subscribers: cfe-commits
>
> Differential Revision: https://reviews.llvm.org/D23120
>
> Modified:
> cfe/trunk/lib/CodeGen/CGBuiltin.cpp
> cfe/trunk/test/CodeGenOpenCL/to_addr_builtin.cl
>
> Modified: cfe/trunk/lib/CodeGen/CGBuiltin.cpp
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGBuiltin.cpp?rev=277743=277742=277743=diff
> ==
> --- cfe/trunk/lib/CodeGen/CGBuiltin.cpp (original)
> +++ cfe/trunk/lib/CodeGen/CGBuiltin.cpp Thu Aug  4 13:06:27 2016
> @@ -2209,8 +2209,9 @@ RValue CodeGenFunction::EmitBuiltinExpr(
>NewArg = Builder.CreateAddrSpaceCast(Arg0, NewArgT);
>  else
>NewArg = Builder.CreateBitOrPointerCast(Arg0, NewArgT);
> -auto NewCall = Builder.CreateCall(CGM.CreateRuntimeFunction(FTy,
> -  E->getDirectCallee()->getName()), {NewArg});
> +auto NewName = std::string("__") + E->getDirectCallee()->getName().str();
> +auto NewCall =
> +Builder.CreateCall(CGM.CreateRuntimeFunction(FTy, NewName),
> + {NewArg});
>  return RValue::get(Builder.CreateBitOrPointerCast(NewCall,
>ConvertType(E->getType(;
>}
>
> Modified: cfe/trunk/test/CodeGenOpenCL/to_addr_builtin.cl
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenOpenCL/to_addr_builtin.cl?rev=277743=277742=277743=diff
> ==
> --- cfe/trunk/test/CodeGenOpenCL/to_addr_builtin.cl (original)
> +++ cfe/trunk/test/CodeGenOpenCL/to_addr_builtin.cl Thu Aug  4 13:06:27
> +++ 2016
> @@ -14,74 +14,74 @@ void test(void) {
>generic int *gen;
>
>//CHECK: %[[ARG:.*]] = addrspacecast i32 addrspace(1)* %{{.*}} to i8 
> addrspace(4)*
> -  //CHECK: %[[RET:.*]] = call i8 addrspace(1)* @to_global(i8 addrspace(4)* 
> %[[ARG]])
> +  //CHECK: %[[RET:.*]] = call i8 addrspace(1)* @__to_global(i8
> + addrspace(4)* %[[ARG]])
>//CHECK: %{{.*}} = bitcast i8 addrspace(1)* %[[RET]] to i32 addrspace(1)*
>glob = to_global(glob);
>
>//CHECK: %[[ARG:.*]] = addrspacecast i32 addrspace(3)* %{{.*}} to i8 
> addrspace(4)*
> -  //CHECK: %[[RET:.*]] = call i8 addrspace(1)* @to_global(i8 addrspace(4)* 
> %[[ARG]])
> +  //CHECK: %[[RET:.*]] = call i8 addrspace(1)* @__to_global(i8
> + addrspace(4)* %[[ARG]])
>//CHECK: %{{.*}} = bitcast i8 addrspace(1)* %[[RET]] to i32 addrspace(1)*
>glob = to_global(loc);
>
>//CHECK: %[[ARG:.*]] = addrspacecast i32* %{{.*}} to i8 addrspace(4)*
> -  //CHECK: %[[RET:.*]] = call i8 addrspace(1)* @to_global(i8 addrspace(4)* 
> %[[ARG]])
> +  //CHECK: %[[RET:.*]] = call i8 addrspace(1)* @__to_global(i8
> + addrspace(4)* %[[ARG]])
>//CHECK: %{{.*}} = bitcast i8 addrspace(1)* %[[RET]] to i32 addrspace(1)*
>glob = to_global(priv);
>
>//CHECK: %[[ARG:.*]] = bitcast i32 addrspace(4)* %{{.*}} to i8 
> addrspace(4)*
> -  //CHECK: %[[RET:.*]] = call i8 addrspace(1)* @to_global(i8 addrspace(4)* 
> %[[ARG]])
> +  //CHECK: %[[RET:.*]] = call i8 addrspace(1)* @__to_global(i8
> + addrspace(4)* %[[ARG]])
>//CHECK: %{{.*}} = bitcast i8 addrspace(1)* %[[RET]] to i32 addrspace(1)*
>glob = to_global(gen);
>
>//CHECK: %[[ARG:.*]] = addrspacecast i32 addrspace(1)* %{{.*}} to i8 
> addrspace(4)*
> -  //CHECK: %[[RET:.*]] = call i8 addrspace(3)* @to_local(i8 addrspace(4)* 
> %[[ARG]])
> +  //CHECK: %[[RET:.*]] = call i8 addrspace(3)* @__to_local(i8
> + addrspace(4)* %[[ARG]])
>//CHECK: %{{.*}} = bitcast i8 addrspace(3)* %[[RET]] to i32 addrspace(3)*
>loc = to_local(glob);
>
>//CHECK: %[[ARG:.*]] = addrspacecast i32 addrspace(3)* %{{.*}} to i8 
> addrspace(4)*
> -  //CHECK: %[[RET:.*]] = call i8 addrspace(3)* @to_local(i8 addrspace(4)* 
> %[[ARG]])
> +  //CHECK: %[[RET:.*]] = call i8 addrspace(3)* @__to_local(i8
> + addrspace(4)* %[[ARG]])
>//CHECK: %{{.*}} = bitcast i8 addrspace(3)* %[[RET]] to i32 addrspace(3)*
>loc = to_local(loc);
>
>

Re: [PATCH] D23272: [analyzer][Rewrite] Fix boxes and shadows in HTML rewrites in Firefox.

2016-08-08 Thread Aleksei Sidorin via cfe-commits
a.sidorin added inline comments.


Comment at: lib/Rewrite/HTMLRewrite.cpp:304
@@ -303,2 +303,3 @@
+  "  border-radius:5px;  box-shadow:1px 1px 7px #000; "
   "  -webkit-border-radius:5px;  -webkit-box-shadow:1px 1px 7px #000; "
   "position: absolute; top: -1em; left:10em; z-index: 1 } \n"

Should we remove '-webkit'-prefixed options as well? AFAIR, non-prefixed 
options should be supported by Webkit. Could you check with Chrome/Safari?


https://reviews.llvm.org/D23272



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


[PATCH] D23272: [analyzer][Rewrite] Fix boxes and shadows in HTML rewrites in Firefox.

2016-08-08 Thread Artem Dergachev via cfe-commits
NoQ created this revision.
NoQ added reviewers: dcoughlin, zaks.anna.
NoQ added subscribers: xazax.hun, a.sidorin, cfe-commits.

Use the official CSS3 properties `border-radius` and `box-shadow` (not only 
`-webkit-`specific properties).

Fixes analyzer's diagnostic pieces in HTML diagnostics mode in Firefox and 
other non-webkit browsers.

Before: {F2254935}
After: {F2254934}

Not sure, do we need more reviewers? - it seems that HTMLRewrite is mostly used 
in the analyzer. Also, are there html/css gurus around? Cause the best thing i 
can do is trust the "a lot of green boxes" feeling at 
http://caniuse.com/#feat=border-radius and 
http://caniuse.com/#feat=css-boxshadow :)

https://reviews.llvm.org/D23272

Files:
  lib/Rewrite/HTMLRewrite.cpp

Index: lib/Rewrite/HTMLRewrite.cpp
===
--- lib/Rewrite/HTMLRewrite.cpp
+++ lib/Rewrite/HTMLRewrite.cpp
@@ -300,6 +300,7 @@
   " .expansion { display: none; }\n"
   " .macro:hover .expansion { display: block; border: 2px solid #FF; "
   "padding: 2px; background-color:#FFF0F0; font-weight: normal; "
+  "  border-radius:5px;  box-shadow:1px 1px 7px #000; "
   "  -webkit-border-radius:5px;  -webkit-box-shadow:1px 1px 7px #000; "
   "position: absolute; top: -1em; left:10em; z-index: 1 } \n"
   " .macro { color: darkmagenta; background-color:LemonChiffon;"
@@ -310,7 +311,9 @@
   " .num { color:#44 }\n"
   " .line { padding-left: 1ex; border-left: 3px solid #ccc }\n"
   " .line { white-space: pre }\n"
+  " .msg { box-shadow:1px 1px 7px #000 }\n"
   " .msg { -webkit-box-shadow:1px 1px 7px #000 }\n"
+  " .msg { border-radius:5px }\n"
   " .msg { -webkit-border-radius:5px }\n"
   " .msg { font-family:Helvetica, sans-serif; font-size:8pt }\n"
   " .msg { float:left }\n"
@@ -325,6 +328,7 @@
   " .mrange { border-bottom:1px solid #6F9DBE }\n"
   " .PathIndex { font-weight: bold; padding:0px 5px; "
 "margin-right:5px; }\n"
+  " .PathIndex { border-radius:8px }\n"
   " .PathIndex { -webkit-border-radius:8px }\n"
   " .PathIndexEvent { background-color:#bfba87 }\n"
   " .PathIndexControl { background-color:#8c8c8c }\n"


Index: lib/Rewrite/HTMLRewrite.cpp
===
--- lib/Rewrite/HTMLRewrite.cpp
+++ lib/Rewrite/HTMLRewrite.cpp
@@ -300,6 +300,7 @@
   " .expansion { display: none; }\n"
   " .macro:hover .expansion { display: block; border: 2px solid #FF; "
   "padding: 2px; background-color:#FFF0F0; font-weight: normal; "
+  "  border-radius:5px;  box-shadow:1px 1px 7px #000; "
   "  -webkit-border-radius:5px;  -webkit-box-shadow:1px 1px 7px #000; "
   "position: absolute; top: -1em; left:10em; z-index: 1 } \n"
   " .macro { color: darkmagenta; background-color:LemonChiffon;"
@@ -310,7 +311,9 @@
   " .num { color:#44 }\n"
   " .line { padding-left: 1ex; border-left: 3px solid #ccc }\n"
   " .line { white-space: pre }\n"
+  " .msg { box-shadow:1px 1px 7px #000 }\n"
   " .msg { -webkit-box-shadow:1px 1px 7px #000 }\n"
+  " .msg { border-radius:5px }\n"
   " .msg { -webkit-border-radius:5px }\n"
   " .msg { font-family:Helvetica, sans-serif; font-size:8pt }\n"
   " .msg { float:left }\n"
@@ -325,6 +328,7 @@
   " .mrange { border-bottom:1px solid #6F9DBE }\n"
   " .PathIndex { font-weight: bold; padding:0px 5px; "
 "margin-right:5px; }\n"
+  " .PathIndex { border-radius:8px }\n"
   " .PathIndex { -webkit-border-radius:8px }\n"
   " .PathIndexEvent { background-color:#bfba87 }\n"
   " .PathIndexControl { background-color:#8c8c8c }\n"
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D23257: Fix clang-tidy crash when a single fix is applied on multiple files.

2016-08-08 Thread Alexander Kornienko via cfe-commits
alexfh added inline comments.


Comment at: test/clang-tidy/Inputs/modernize-pass-by-value/header-with-fix.h:1
@@ +1,2 @@
+#include 
+

hokein wrote:
> Usually test should not use STL headers as it relies on the system headers.
> 
> You don't have to use std::string to reproduce the crash, IMO.
Yep, just a class with a user-defined move constructor should be fine.

```
// .h file:
struct S {
  S(S&&);
  S(const S&);
};
struct Foo {
  Foo(const S );
  S s;
};

// .cpp file:
#include "a.h"
Foo::Foo(const S ) : s(s) {}
```


https://reviews.llvm.org/D23257



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


Re: [PATCH] D22856: [analyzer] Change -analyze-function to accept qualified names.

2016-08-08 Thread Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL278018: [analyzer] Change -analyze-function to accept 
qualified names. (authored by dergachev).

Changed prior to commit:
  https://reviews.llvm.org/D22856?vs=66360=67180#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D22856

Files:
  cfe/trunk/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp
  cfe/trunk/test/Analysis/analyzeOneFunction.m
  cfe/trunk/test/Analysis/analyze_display_progress.cpp
  cfe/trunk/test/Analysis/analyzer-display-progress.cpp
  cfe/trunk/test/Analysis/analyzer-display-progress.m

Index: cfe/trunk/test/Analysis/analyzer-display-progress.cpp
===
--- cfe/trunk/test/Analysis/analyzer-display-progress.cpp
+++ cfe/trunk/test/Analysis/analyzer-display-progress.cpp
@@ -0,0 +1,30 @@
+// RUN: %clang_cc1 -analyze -analyzer-display-progress %s 2>&1 | FileCheck %s
+
+void f() {};
+void g() {};
+void h() {}
+
+struct SomeStruct {
+  void f() {}
+};
+
+struct SomeOtherStruct {
+  void f() {}
+};
+
+namespace ns {
+  struct SomeStruct {
+void f(int) {}
+void f(float, ::SomeStruct) {}
+void f(float, SomeStruct) {}
+  };
+}
+
+// CHECK: analyzer-display-progress.cpp f()
+// CHECK: analyzer-display-progress.cpp g()
+// CHECK: analyzer-display-progress.cpp h()
+// CHECK: analyzer-display-progress.cpp SomeStruct::f()
+// CHECK: analyzer-display-progress.cpp SomeOtherStruct::f()
+// CHECK: analyzer-display-progress.cpp ns::SomeStruct::f(int)
+// CHECK: analyzer-display-progress.cpp ns::SomeStruct::f(float, ::SomeStruct)
+// CHECK: analyzer-display-progress.cpp ns::SomeStruct::f(float, struct ns::SomeStruct)
Index: cfe/trunk/test/Analysis/analyzeOneFunction.m
===
--- cfe/trunk/test/Analysis/analyzeOneFunction.m
+++ cfe/trunk/test/Analysis/analyzeOneFunction.m
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -analyze -analyze-function="myMethodWithY:withX:" -analyzer-checker=core,osx.cocoa.RetainCount -analyzer-store=region -verify %s
+// RUN: %clang_cc1 -analyze -analyze-function="-[Test1 myMethodWithY:withX:]" -analyzer-checker=core,osx.cocoa.RetainCount -analyzer-store=region -verify %s
 
 typedef signed char BOOL;
 typedef unsigned int NSUInteger;
Index: cfe/trunk/test/Analysis/analyzer-display-progress.m
===
--- cfe/trunk/test/Analysis/analyzer-display-progress.m
+++ cfe/trunk/test/Analysis/analyzer-display-progress.m
@@ -0,0 +1,30 @@
+// RUN: %clang_cc1 -fblocks -analyze -analyzer-display-progress %s 2>&1 | FileCheck %s
+
+#include "Inputs/system-header-simulator-objc.h"
+
+static void f() {}
+
+@interface I: NSObject
+-(void)instanceMethod:(int)arg1 with:(int)arg2;
++(void)classMethod;
+@end
+
+@implementation I
+-(void)instanceMethod:(int)arg1 with:(int)arg2 {}
++(void)classMethod {}
+@end
+
+void g(I *i, int x, int y) {
+  [I classMethod];
+  [i instanceMethod: x with: y];
+
+  void (^block)(void);
+  block = ^{};
+  block();
+}
+
+// CHECK: analyzer-display-progress.m f
+// CHECK: analyzer-display-progress.m -[I instanceMethod:with:]
+// CHECK: analyzer-display-progress.m +[I classMethod]
+// CHECK: analyzer-display-progress.m g
+// CHECK: analyzer-display-progress.m block (line: 22, col: 11)
Index: cfe/trunk/test/Analysis/analyze_display_progress.cpp
===
--- cfe/trunk/test/Analysis/analyze_display_progress.cpp
+++ cfe/trunk/test/Analysis/analyze_display_progress.cpp
@@ -1,26 +0,0 @@
-// RUN: %clang_cc1 -analyze -analyzer-display-progress %s 2>&1 | FileCheck %s
-
-void f() {};
-void g() {};
-void h() {}
-
-struct SomeStruct {
-  void f() {}
-};
-
-struct SomeOtherStruct {
-  void f() {}
-};
-
-namespace ns {
-  struct SomeStruct {
-void f() {}
-  };
-}
-
-// CHECK: analyze_display_progress.cpp f
-// CHECK: analyze_display_progress.cpp g
-// CHECK: analyze_display_progress.cpp h
-// CHECK: analyze_display_progress.cpp SomeStruct::f
-// CHECK: analyze_display_progress.cpp SomeOtherStruct::f
-// CHECK: analyze_display_progress.cpp ns::SomeStruct::f
Index: cfe/trunk/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp
===
--- cfe/trunk/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp
+++ cfe/trunk/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp
@@ -265,19 +265,8 @@
   else
 assert(Mode == (AM_Syntax | AM_Path) && "Unexpected mode!");
 
-  llvm::errs() << ": " << Loc.getFilename();
-  if (isa(D) || isa(D)) {
-const NamedDecl *ND = cast(D);
-llvm::errs() << ' ' << ND->getQualifiedNameAsString() << '\n';
-  }
-  else if (isa(D)) {
-llvm::errs() << ' ' << "block(line:" << Loc.getLine() << ",col:"
- << Loc.getColumn() << '\n';
-  }
-  else if (const ObjCMethodDecl *MD = dyn_cast(D)) {
-Selector S = 

Re: [PATCH] D23193: [clang-rename] fix bug with initializer lists

2016-08-08 Thread Alexander Kornienko via cfe-commits
alexfh added a comment.

In https://reviews.llvm.org/D23193#508563, @omtcyfz wrote:

> Do these symbolic pointers in test seem reasonable?


Yes, kind of. I'd change these to C-style comments, place them on the same line 
with the interesting identifier (probably, right after the identifier), and 
document a generic way of finding the offset using `grep -Ubo 'Foo.*'` or 
whatever grep flags are needed.

For example:

  $ cat /tmp/a.h 
  #include 
  
  struct Foo /* test 1 */ {
Foo /* test 2 */ (const std::string );
std::string s;
  };
  
  // Test 1.
  // RUN: . -offset=26 ...
  // Test2.
  // RUN: . -offset=47 ...
  
  // To find offsets after modifying the file, use:
  //   grep -Ubo 'Foo.*' 
  $ grep -Ubo 'Foo.*' /tmp/a.h 
  26:Foo /* test 1 */ {
  47:Foo /* test 2 */ (const std::string );
  255:Foo.*' 


https://reviews.llvm.org/D23193



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


Re: [PATCH] D23266: [include-fixer] Support processing multiple files in one run.

2016-08-08 Thread Benjamin Kramer via cfe-commits
bkramer accepted this revision.
bkramer added a comment.
This revision is now accepted and ready to land.

lgtm



Comment at: include-fixer/IncludeFixerContext.h:78
@@ -72,1 +77,3 @@
 
+  /// \brief The absolute path to the file being processed.
+  std::string FilePath;

I don't think there are any guarantees about that.


https://reviews.llvm.org/D23266



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


Re: [PATCH] D23266: [include-fixer] Support processing multiple files in one run.

2016-08-08 Thread Haojian Wu via cfe-commits
hokein updated this revision to Diff 67178.
hokein marked 2 inline comments as done.
hokein added a comment.

Address review comments.


https://reviews.llvm.org/D23266

Files:
  include-fixer/IncludeFixer.cpp
  include-fixer/IncludeFixer.h
  include-fixer/IncludeFixerContext.cpp
  include-fixer/IncludeFixerContext.h
  include-fixer/tool/ClangIncludeFixer.cpp
  include-fixer/tool/clang-include-fixer.py
  test/include-fixer/commandline_options.cpp
  test/include-fixer/multiple_fixes.cpp
  unittests/include-fixer/IncludeFixerTest.cpp

Index: unittests/include-fixer/IncludeFixerTest.cpp
===
--- unittests/include-fixer/IncludeFixerTest.cpp
+++ unittests/include-fixer/IncludeFixerTest.cpp
@@ -88,15 +88,15 @@
   SymbolIndexMgr->addSymbolIndex(
   llvm::make_unique(Symbols));
 
-  IncludeFixerContext FixerContext;
-  IncludeFixerActionFactory Factory(*SymbolIndexMgr, FixerContext, "llvm");
-
+  std::vector FixerContexts;
+  IncludeFixerActionFactory Factory(*SymbolIndexMgr, FixerContexts, "llvm");
   std::string FakeFileName = "input.cc";
   runOnCode(, Code, FakeFileName, ExtraArgs);
-  if (FixerContext.getHeaderInfos().empty())
+  assert(FixerContexts.size() == 1);
+  if (FixerContexts.front().getHeaderInfos().empty())
 return Code;
   auto Replaces = clang::include_fixer::createIncludeFixerReplacements(
-  Code, FakeFileName, FixerContext);
+  Code, FixerContexts.front());
   EXPECT_TRUE(static_cast(Replaces))
   << llvm::toString(Replaces.takeError()) << "\n";
   if (!Replaces)
Index: test/include-fixer/multiple_fixes.cpp
===
--- /dev/null
+++ test/include-fixer/multiple_fixes.cpp
@@ -0,0 +1,13 @@
+// REQUIRES: shell
+// RUN: sed -e 's#//.*$##' %s > %t.cpp
+// RUN: mkdir -p %T/include-fixer/multiple-fixes
+// RUN: echo 'foo f;' > %T/include-fixer/multiple-fixes/foo.cpp
+// RUN: echo 'bar b;' > %T/include-fixer/multiple-fixes/bar.cpp
+// RUN: clang-include-fixer -db=fixed -input='foo= "foo.h";bar= "bar.h"' %T/include-fixer/multiple-fixes/*.cpp --
+// RUN: FileCheck -input-file=%T/include-fixer/multiple-fixes/bar.cpp %s -check-prefix=CHECK-BAR
+// RUN: FileCheck -input-file=%T/include-fixer/multiple-fixes/foo.cpp %s -check-prefix=CHECK-FOO
+//
+// CHECK-FOO: #include "foo.h"
+// CHECK-FOO: foo f;
+// CHECK-BAR: #include "bar.h"
+// CHECK-BAR: bar b;
Index: test/include-fixer/commandline_options.cpp
===
--- test/include-fixer/commandline_options.cpp
+++ test/include-fixer/commandline_options.cpp
@@ -1,9 +1,9 @@
 // REQUIRES: shell
 // RUN: echo "foo f;" > %t.cpp
 // RUN: clang-include-fixer -db=fixed -input='foo= "foo.h","bar.h"' -output-headers %t.cpp -- | FileCheck %s
-// RUN: cat %t.cpp | clang-include-fixer -stdin -insert-header='{QuerySymbolInfos: [{RawIdentifier: foo, Range: {Offset: 0, Length: 3}}], HeaderInfos: [{Header: "\"foo.h\"", QualifiedName: "foo"}]}' %t.cpp | FileCheck %s -check-prefix=CHECK-CODE
-// RUN: cat %t.cpp | not clang-include-fixer -stdin -insert-header='{QuerySymbolInfos: [{RawIdentifier: foo, Range: {Offset: 0, Length: 3}}], HeaderInfos: [{Header: "\"foo.h\"", QualifiedName: "foo"},{Header: "\"foo2.h\"", QualifiedName: "foo"}]}' %t.cpp
-// RUN: cat %t.cpp | clang-include-fixer -stdin -insert-header='{QuerySymbolInfos: [{RawIdentifier: foo, Range: {Offset: 0, Length: 3}}], HeaderInfos: [{Header: "\"foo.h\"", QualifiedName: "a:foo"},{Header: "\"foo.h\"", QualifiedName: "b:foo"}]}' %t.cpp
+// RUN: cat %t.cpp | clang-include-fixer -stdin -insert-header='{FilePath: %t.cpp, QuerySymbolInfos: [{RawIdentifier: foo, Range: {Offset: 0, Length: 3}}], HeaderInfos: [{Header: "\"foo.h\"", QualifiedName: "foo"}]}' %t.cpp | FileCheck %s -check-prefix=CHECK-CODE
+// RUN: cat %t.cpp | not clang-include-fixer -stdin -insert-header='{FilePath: %t.cpp, QuerySymbolInfos: [{RawIdentifier: foo, Range: {Offset: 0, Length: 3}}], HeaderInfos: [{Header: "\"foo.h\"", QualifiedName: "foo"},{Header: "\"foo2.h\"", QualifiedName: "foo"}]}' %t.cpp
+// RUN: cat %t.cpp | clang-include-fixer -stdin -insert-header='{FilePath: %t.cpp, QuerySymbolInfos: [{RawIdentifier: foo, Range: {Offset: 0, Length: 3}}], HeaderInfos: [{Header: "\"foo.h\"", QualifiedName: "a:foo"},{Header: "\"foo.h\"", QualifiedName: "b:foo"}]}' %t.cpp
 //
 // CHECK: "HeaderInfos": [
 // CHECK-NEXT:  {"Header": "\"foo.h\"",
Index: include-fixer/tool/clang-include-fixer.py
===
--- include-fixer/tool/clang-include-fixer.py
+++ include-fixer/tool/clang-include-fixer.py
@@ -149,21 +149,16 @@
 return
 
   try:
-# If there is only one suggested header, insert it directly.
-if len(unique_headers) == 1 or maximum_suggested_headers == 1:
-  InsertHeaderToVimBuffer({"QuerySymbolInfos": query_symbol_infos,
-   "HeaderInfos": header_infos}, text)
- 

Re: [PATCH] D23130: Add a check for definitions in the global namespace.

2016-08-08 Thread David Blaikie via cfe-commits
On Mon, Aug 8, 2016 at 8:37 AM Benjamin Kramer  wrote:

> -Wmissing-prototype only warns for functions, I want to catch classes
> too.


Ah, fair enough. Yeah, a clang-tidy check for things in the global
namespace that are in a main file rather than a header could be another
pivot there.


> Also functions in the global namespace with a prototype are still
> badness in some coding styles.


*nod* makes sense - especially in C++, where, as you say, you might want to
bless the extern "C" function declarations only.


> The limitation on definitions was to
> cut down on false positives, the current version of the patch doesn't
> have that limitation but I'm pondering on putting it back as there are
> too many false positives.
>
> On Mon, Aug 8, 2016 at 5:34 PM, David Blaikie  wrote:
> > This seems to have a lot of overlap with -Wmissing-prototype, really -
> what
> > do you think of the overlap/distinction between the two?
> >
> > On Wed, Aug 3, 2016 at 1:25 PM Eugene Zelenko via cfe-commits
> >  wrote:
> >>
> >> Eugene.Zelenko added a subscriber: Eugene.Zelenko.
> >> Eugene.Zelenko added a comment.
> >>
> >> Please mention this check in docs/ReleaseNotes.rst (in alphabetical
> >> order).
> >>
> >>
> >> https://reviews.llvm.org/D23130
> >>
> >>
> >>
> >> ___
> >> 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: [PATCH] D21134: clang-tidy: new check readability-misplaced-array-index

2016-08-08 Thread Aaron Ballman via cfe-commits
aaron.ballman added inline comments.


Comment at: clang-tidy/readability/MisplacedArrayIndexCheck.cpp:48
@@ +47,3 @@
+
+  auto D =
+  diag(ArraySubscriptE->getLocStart(),

alexfh wrote:
> aaron.ballman wrote:
> > Should not use `auto` here because the type is not spelled out in the 
> > initialization.
> While in general I agree with this recommendation, `auto Diag = diag(...);` 
> has almost become an idiom in this code. I'd not worry about obscurity of 
> `auto` in this context, especially, if the variable is renamed to `Diag`, 
> which will make its meaning and possible ways of using it clearer.
I'm okay with that approach.


https://reviews.llvm.org/D21134



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


Re: [PATCH] D23243: [clang-tidy] enhance modernize-use-bool-literals to check ternary operator

2016-08-08 Thread Alexander Kornienko via cfe-commits
alexfh requested changes to this revision.
This revision now requires changes to proceed.


Comment at: clang-tidy/modernize/UseBoolLiteralsCheck.cpp:39
@@ +38,3 @@
+  eachOf(
+  // anyOf() is not evaluating second argument if first is 
evaluated
+  // as

Remove `anyOf` and `anything`. And the comment.


https://reviews.llvm.org/D23243



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


Re: [PATCH] D22045: [X86] Support of no_caller_saved_registers attribute (Clang part)

2016-08-08 Thread Aaron Ballman via cfe-commits
On Mon, Aug 8, 2016 at 11:50 AM, H.J Lu  wrote:
> hjl.tools added a comment.
>
> In https://reviews.llvm.org/D22045#508648, @aaron.ballman wrote:
>
>> In https://reviews.llvm.org/D22045#508644, @hjl.tools wrote:
>>
>> > In https://reviews.llvm.org/D22045#506996, @joerg wrote:
>> >
>> > > For what it is worth, this certainly seems to be misnamed. By nature, if 
>> > > it doesn't preserve at least the stack pointer, there is no way to 
>> > > recover on return, right?
>> >
>> >
>> > This is the best name we came up with and has been implemented in GCC.
>>
>>
>> What version of GCC supports this attribute? I tried 6.1.0 and it is unknown 
>> there.
>
>
> It is implemented in GCC 7.

Okay, that is good to know! Then the attribute should be using the GCC
spelling rather than the GNU spelling. This also obviates the need for
an explicit CXX11 spelling under the clang:: namespace, if our
intention is for this attribute to match GCC's behavior.

~Aaron

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


Re: [PATCH] D21134: clang-tidy: new check readability-misplaced-array-index

2016-08-08 Thread Alexander Kornienko via cfe-commits
alexfh added inline comments.


Comment at: clang-tidy/readability/MisplacedArrayIndexCheck.cpp:48
@@ +47,3 @@
+
+  auto D =
+  diag(ArraySubscriptE->getLocStart(),

aaron.ballman wrote:
> Should not use `auto` here because the type is not spelled out in the 
> initialization.
While in general I agree with this recommendation, `auto Diag = diag(...);` has 
almost become an idiom in this code. I'd not worry about obscurity of `auto` in 
this context, especially, if the variable is renamed to `Diag`, which will make 
its meaning and possible ways of using it clearer.


https://reviews.llvm.org/D21134



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


Re: [PATCH] D22862: [analyzer] Fix for PR15623: eliminate unwanted ProgramState checker data propagation.

2016-08-08 Thread Artem Dergachev via cfe-commits
NoQ added a comment.

Hmm. The test in `unwanted-programstate-data-propagation.c` passes on my 
machine even without the patch, and the return value on the respective path is 
correctly represented as `(conj_$6{void *}) != 0U`, which comes from the 
`evalCast()` call in `VisitLogicalExpr()` and is the default behavior of 
`evalCast()` for Loc to pointer casts. There seems to be something amiss.


https://reviews.llvm.org/D22862



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


Re: [PATCH] D23266: [include-fixer] Support processing multiple files in one run.

2016-08-08 Thread Haojian Wu via cfe-commits
hokein added a comment.

> Can you add a lit test for this? We should've added that earlier :|


I forgot to upload the test first time. But I have already uploaded it, see 
`multiple_fixes.cpp`



Comment at: include-fixer/IncludeFixerContext.h:78
@@ -72,1 +77,3 @@
 
+  /// \brief The absolute path to the file being processed.
+  std::string FilePath;

It depends on `InFile` parameter in 
`clang::ASTFrontendAction::CreateASTConsumer` method. Isn't it always an 
absolute file path?


https://reviews.llvm.org/D23266



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


Re: [PATCH] D23257: Fix clang-tidy crash when a single fix is applied on multiple files.

2016-08-08 Thread Haojian Wu via cfe-commits
hokein added inline comments.


Comment at: test/clang-tidy/Inputs/modernize-pass-by-value/header-with-fix.h:1
@@ +1,2 @@
+#include 
+

Usually test should not use STL headers as it relies on the system headers.

You don't have to use std::string to reproduce the crash, IMO.


https://reviews.llvm.org/D23257



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


Re: [PATCH] D22045: [X86] Support of no_caller_saved_registers attribute (Clang part)

2016-08-08 Thread Erich Keane via cfe-commits
erichkeane added a comment.

In https://reviews.llvm.org/D22045#508648, @aaron.ballman wrote:

> In https://reviews.llvm.org/D22045#508644, @hjl.tools wrote:
>
> > In https://reviews.llvm.org/D22045#506996, @joerg wrote:
> >
> > > For what it is worth, this certainly seems to be misnamed. By nature, if 
> > > it doesn't preserve at least the stack pointer, there is no way to 
> > > recover on return, right?
> >
> >
> > This is the best name we came up with and has been implemented in GCC.
>
>
> What version of GCC supports this attribute? I tried 6.1.0 and it is unknown 
> there.


I see reference to it in this bug against 6.0: 
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=68661


https://reviews.llvm.org/D22045



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


Re: [PATCH] D22045: [X86] Support of no_caller_saved_registers attribute (Clang part)

2016-08-08 Thread Aaron Ballman via cfe-commits
aaron.ballman added a comment.

In https://reviews.llvm.org/D22045#508644, @hjl.tools wrote:

> In https://reviews.llvm.org/D22045#506996, @joerg wrote:
>
> > For what it is worth, this certainly seems to be misnamed. By nature, if it 
> > doesn't preserve at least the stack pointer, there is no way to recover on 
> > return, right?
>
>
> This is the best name we came up with and has been implemented in GCC.


What version of GCC supports this attribute? I tried 6.1.0 and it is unknown 
there.


https://reviews.llvm.org/D22045



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


Re: [PATCH] D21134: clang-tidy: new check readability-misplaced-array-index

2016-08-08 Thread Alexander Kornienko via cfe-commits
alexfh added a comment.

In https://reviews.llvm.org/D21134#508524, @jroelofs wrote:

> I think the replacement is wrong for something like:
>
>   int *arr; int offs1, offs2;
>   offs1[arr + offs2] = 42;
>
>
> which I think would give:
>
>   int *arr; int offs1, offs2;
>   arr + offs2[offs1] = 42;
>
>
> If the precedence of the "indexing" argument is less than that of the 
> subscript operator, then you need to insert parens:
>
>   int *arr; int offs1, offs2;
>   (arr + offs2)[offs1] = 42;
>


Indeed. It might be relevant to future (current ones seem to be fine) uses of 
`tooling::fixit::createReplacement` as well, so should probably be taken care 
of  in its implementation. Maybe an additional hint from the calling code is 
needed (`bool InsertParensIfNeeded = false`).


https://reviews.llvm.org/D21134



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


Re: [PATCH] D22045: [X86] Support of no_caller_saved_registers attribute (Clang part)

2016-08-08 Thread H.J Lu via cfe-commits
hjl.tools added a comment.

In https://reviews.llvm.org/D22045#506996, @joerg wrote:

> For what it is worth, this certainly seems to be misnamed. By nature, if it 
> doesn't preserve at least the stack pointer, there is no way to recover on 
> return, right?


This is the best name we came up with and has been implemented in GCC.


https://reviews.llvm.org/D22045



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


Re: [PATCH] D23130: Add a check for definitions in the global namespace.

2016-08-08 Thread Benjamin Kramer via cfe-commits
-Wmissing-prototype only warns for functions, I want to catch classes
too. Also functions in the global namespace with a prototype are still
badness in some coding styles. The limitation on definitions was to
cut down on false positives, the current version of the patch doesn't
have that limitation but I'm pondering on putting it back as there are
too many false positives.

On Mon, Aug 8, 2016 at 5:34 PM, David Blaikie  wrote:
> This seems to have a lot of overlap with -Wmissing-prototype, really - what
> do you think of the overlap/distinction between the two?
>
> On Wed, Aug 3, 2016 at 1:25 PM Eugene Zelenko via cfe-commits
>  wrote:
>>
>> Eugene.Zelenko added a subscriber: Eugene.Zelenko.
>> Eugene.Zelenko added a comment.
>>
>> Please mention this check in docs/ReleaseNotes.rst (in alphabetical
>> order).
>>
>>
>> https://reviews.llvm.org/D23130
>>
>>
>>
>> ___
>> 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: [PATCH] D23196: [ARM] Command-line options for embedded position-independent code

2016-08-08 Thread Oliver Stannard via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL278016: [ARM] Command-line options for embedded 
position-independent code (authored by olista01).

Changed prior to commit:
  https://reviews.llvm.org/D23196?vs=66921=67176#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D23196

Files:
  cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td
  cfe/trunk/include/clang/Driver/Options.td
  cfe/trunk/lib/CodeGen/BackendUtil.cpp
  cfe/trunk/lib/Driver/Tools.cpp
  cfe/trunk/test/Driver/ropi-rwpi.c

Index: cfe/trunk/lib/CodeGen/BackendUtil.cpp
===
--- cfe/trunk/lib/CodeGen/BackendUtil.cpp
+++ cfe/trunk/lib/CodeGen/BackendUtil.cpp
@@ -525,6 +525,12 @@
 RM = llvm::Reloc::Static;
   } else if (CodeGenOpts.RelocationModel == "pic") {
 RM = llvm::Reloc::PIC_;
+  } else if (CodeGenOpts.RelocationModel == "ropi") {
+RM = llvm::Reloc::ROPI;
+  } else if (CodeGenOpts.RelocationModel == "rwpi") {
+RM = llvm::Reloc::RWPI;
+  } else if (CodeGenOpts.RelocationModel == "ropi-rwpi") {
+RM = llvm::Reloc::ROPI_RWPI;
   } else {
 assert(CodeGenOpts.RelocationModel == "dynamic-no-pic" &&
"Invalid PIC model!");
Index: cfe/trunk/lib/Driver/Tools.cpp
===
--- cfe/trunk/lib/Driver/Tools.cpp
+++ cfe/trunk/lib/Driver/Tools.cpp
@@ -3777,10 +3777,52 @@
 return std::make_tuple(llvm::Reloc::DynamicNoPIC, PIC ? 2U : 0U, false);
   }
 
+  bool EmbeddedPISupported;
+  switch (ToolChain.getArch()) {
+case llvm::Triple::arm:
+case llvm::Triple::armeb:
+case llvm::Triple::thumb:
+case llvm::Triple::thumbeb:
+  EmbeddedPISupported = true;
+  break;
+default:
+  EmbeddedPISupported = false;
+  break;
+  }
+
+  bool ROPI = false, RWPI = false;
+  Arg* LastROPIArg = Args.getLastArg(options::OPT_fropi, options::OPT_fno_ropi);
+  if (LastROPIArg && LastROPIArg->getOption().matches(options::OPT_fropi)) {
+if (!EmbeddedPISupported)
+  ToolChain.getDriver().Diag(diag::err_drv_unsupported_opt_for_target)
+  << LastROPIArg->getSpelling() << ToolChain.getTriple().str();
+ROPI = true;
+  }
+  Arg *LastRWPIArg = Args.getLastArg(options::OPT_frwpi, options::OPT_fno_rwpi);
+  if (LastRWPIArg && LastRWPIArg->getOption().matches(options::OPT_frwpi)) {
+if (!EmbeddedPISupported)
+  ToolChain.getDriver().Diag(diag::err_drv_unsupported_opt_for_target)
+  << LastRWPIArg->getSpelling() << ToolChain.getTriple().str();
+RWPI = true;
+  }
+
+  // ROPI and RWPI are not comaptible with PIC or PIE.
+  if ((ROPI || RWPI) && (PIC || PIE)) {
+ToolChain.getDriver().Diag(diag::err_drv_ropi_rwpi_incompatible_with_pic);
+  }
+
   if (PIC)
 return std::make_tuple(llvm::Reloc::PIC_, IsPICLevelTwo ? 2U : 1U, PIE);
 
-  return std::make_tuple(llvm::Reloc::Static, 0U, false);
+  llvm::Reloc::Model RelocM = llvm::Reloc::Static;
+  if (ROPI && RWPI)
+RelocM = llvm::Reloc::ROPI_RWPI;
+  else if (ROPI)
+RelocM = llvm::Reloc::ROPI;
+  else if (RWPI)
+RelocM = llvm::Reloc::RWPI;
+
+  return std::make_tuple(RelocM, 0U, false);
 }
 
 static const char *RelocationModelName(llvm::Reloc::Model Model) {
@@ -3791,6 +3833,12 @@
 return "pic";
   case llvm::Reloc::DynamicNoPIC:
 return "dynamic-no-pic";
+  case llvm::Reloc::ROPI:
+return "ropi";
+  case llvm::Reloc::RWPI:
+return "rwpi";
+  case llvm::Reloc::ROPI_RWPI:
+return "ropi-rwpi";
   }
   llvm_unreachable("Unknown Reloc::Model kind");
 }
@@ -4075,6 +4123,13 @@
   ParsePICArgs(getToolChain(), Triple, Args);
 
   const char *RMName = RelocationModelName(RelocationModel);
+
+  if ((RelocationModel == llvm::Reloc::ROPI ||
+   RelocationModel == llvm::Reloc::ROPI_RWPI) &&
+  types::isCXX(Input.getType()) &&
+  !Args.hasArg(options::OPT_fallow_unsupported))
+D.Diag(diag::err_drv_ropi_incompatible_with_cxx);
+
   if (RMName) {
 CmdArgs.push_back("-mrelocation-model");
 CmdArgs.push_back(RMName);
Index: cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td
===
--- cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td
+++ cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td
@@ -240,6 +240,11 @@
 def warn_drv_invoking_fallback : Warning<"falling back to %0">,
   InGroup;
 
+def err_drv_ropi_rwpi_incompatible_with_pic : Error<
+  "embedded and GOT-based position independence are incompatible">;
+def err_drv_ropi_incompatible_with_cxx : Error<
+  "ROPI is not compatible with c++">;
+
 def warn_target_unsupported_nan2008 : Warning<
   "ignoring '-mnan=2008' option because the '%0' architecture does not support it">,
   InGroup;
Index: cfe/trunk/include/clang/Driver/Options.td
===
--- cfe/trunk/include/clang/Driver/Options.td
+++ cfe/trunk/include/clang/Driver/Options.td
@@ 

r278016 - [ARM] Command-line options for embedded position-independent code

2016-08-08 Thread Oliver Stannard via cfe-commits
Author: olista01
Date: Mon Aug  8 10:28:40 2016
New Revision: 278016

URL: http://llvm.org/viewvc/llvm-project?rev=278016=rev
Log:
[ARM] Command-line options for embedded position-independent code

This patch (with the corresponding ARM backend patch) adds support for
some new relocation models:

* Read-only position independence (ROPI): Code and read-only data is accessed
  PC-relative. The offsets between all code and RO data sections are known at
  static link time.
* Read-write position independence (RWPI): Read-write data is accessed relative
  to a static base register. The offsets between all writeable data sections
  are known at static link time.

These two modes are independent (they specify how different objects
should be addressed), so they can be used individually or together.

These modes are intended for bare-metal systems or systems with small
real-time operating systems. They are designed to avoid the need for a
dynamic linker, the only initialisation required is setting the static
base register to an appropriate value for RWPI code.

There is one C construct not currently supported by these modes: global
variables initialised to the address of another global variable or
function, where that address is not known at static-link time. There are
a few possible ways to solve this:

* Disallow this, and require the user to write their own initialisation
  function if they need variables like this.
* Emit dynamic initialisers for these variables in the compiler, called from
  the .init_array section (as is currently done for C++ dynamic initialisers).
  We have a patch to do this, described in my original RFC email
  (http://lists.llvm.org/pipermail/llvm-dev/2015-December/093022.html), but the
  feedback from that RFC thread was that this is not something that belongs in
  clang.
* Use a small dynamic loader to fix up these variables, by adding the
  difference between the load and execution address of the relevant section.
  This would require linker co-operation to generate a table of addresses that
  need fixing up.

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


Added:
cfe/trunk/test/Driver/ropi-rwpi.c
Modified:
cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td
cfe/trunk/include/clang/Driver/Options.td
cfe/trunk/lib/CodeGen/BackendUtil.cpp
cfe/trunk/lib/Driver/Tools.cpp

Modified: cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td?rev=278016=278015=278016=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td Mon Aug  8 10:28:40 
2016
@@ -240,6 +240,11 @@ def err_test_module_file_extension_forma
 def warn_drv_invoking_fallback : Warning<"falling back to %0">,
   InGroup;
 
+def err_drv_ropi_rwpi_incompatible_with_pic : Error<
+  "embedded and GOT-based position independence are incompatible">;
+def err_drv_ropi_incompatible_with_cxx : Error<
+  "ROPI is not compatible with c++">;
+
 def warn_target_unsupported_nan2008 : Warning<
   "ignoring '-mnan=2008' option because the '%0' architecture does not support 
it">,
   InGroup;

Modified: cfe/trunk/include/clang/Driver/Options.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Options.td?rev=278016=278015=278016=diff
==
--- cfe/trunk/include/clang/Driver/Options.td (original)
+++ cfe/trunk/include/clang/Driver/Options.td Mon Aug  8 10:28:40 2016
@@ -1087,6 +1087,10 @@ def fpic : Flag<["-"], "fpic">, Group, Group;
 def fpie : Flag<["-"], "fpie">, Group;
 def fno_pie : Flag<["-"], "fno-pie">, Group;
+def fropi : Flag<["-"], "fropi">, Group;
+def fno_ropi : Flag<["-"], "fno-ropi">, Group;
+def frwpi : Flag<["-"], "frwpi">, Group;
+def fno_rwpi : Flag<["-"], "fno-rwpi">, Group;
 def fplugin_EQ : Joined<["-"], "fplugin=">, Group, 
Flags<[DriverOption]>, MetaVarName<"">,
   HelpText<"Load the named plugin (dynamic shared object)">;
 def fpreserve_as_comments : Flag<["-"], "fpreserve-as-comments">, 
Group;

Modified: cfe/trunk/lib/CodeGen/BackendUtil.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/BackendUtil.cpp?rev=278016=278015=278016=diff
==
--- cfe/trunk/lib/CodeGen/BackendUtil.cpp (original)
+++ cfe/trunk/lib/CodeGen/BackendUtil.cpp Mon Aug  8 10:28:40 2016
@@ -525,6 +525,12 @@ void EmitAssemblyHelper::CreateTargetMac
 RM = llvm::Reloc::Static;
   } else if (CodeGenOpts.RelocationModel == "pic") {
 RM = llvm::Reloc::PIC_;
+  } else if (CodeGenOpts.RelocationModel == "ropi") {
+RM = llvm::Reloc::ROPI;
+  } else if (CodeGenOpts.RelocationModel == "rwpi") {
+RM = llvm::Reloc::RWPI;
+  } else if (CodeGenOpts.RelocationModel == "ropi-rwpi") {
+RM 

Re: [clang-tools-extra] r277677 - [clang-tidy] Inefficient string operation

2016-08-08 Thread David Blaikie via cfe-commits
On Wed, Aug 3, 2016 at 4:13 PM Alexander Kornienko via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: alexfh
> Date: Wed Aug  3 18:06:03 2016
> New Revision: 277677
>
> URL: http://llvm.org/viewvc/llvm-project?rev=277677=rev
> Log:
> [clang-tidy] Inefficient string operation
>

A more detailed commit message might be nice. The code review included some
information that might've been a good start:

"This checker is to warn about the performance overhead caused by
concatenating strings using the operator+ instead of basic_string's append
or operator+=. It is configurable. In strict mode it matches every instance
of a supposed inefficient concatenation, in non-strict mode it matches only
those which are inside a loop."


>
> Patch by Bittner Barni!
>
> Differential revision: https://reviews.llvm.org/D20196
>
> Added:
>
> clang-tools-extra/trunk/clang-tidy/performance/InefficientStringConcatenationCheck.cpp
>
> clang-tools-extra/trunk/clang-tidy/performance/InefficientStringConcatenationCheck.h
>
> clang-tools-extra/trunk/docs/clang-tidy/checks/performance-inefficient-string-concatenation.rst
>
> clang-tools-extra/trunk/test/clang-tidy/performance-inefficient-string-concatenation.cpp
> Modified:
> clang-tools-extra/trunk/clang-tidy/performance/CMakeLists.txt
>
> clang-tools-extra/trunk/clang-tidy/performance/PerformanceTidyModule.cpp
> clang-tools-extra/trunk/docs/ReleaseNotes.rst
> clang-tools-extra/trunk/docs/clang-tidy/checks/list.rst
>
> Modified: clang-tools-extra/trunk/clang-tidy/performance/CMakeLists.txt
> URL:
> http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/performance/CMakeLists.txt?rev=277677=277676=277677=diff
>
> ==
> --- clang-tools-extra/trunk/clang-tidy/performance/CMakeLists.txt
> (original)
> +++ clang-tools-extra/trunk/clang-tidy/performance/CMakeLists.txt Wed Aug
> 3 18:06:03 2016
> @@ -4,6 +4,7 @@ add_clang_library(clangTidyPerformanceMo
>FasterStringFindCheck.cpp
>ForRangeCopyCheck.cpp
>ImplicitCastInLoopCheck.cpp
> +  InefficientStringConcatenationCheck.cpp
>PerformanceTidyModule.cpp
>UnnecessaryCopyInitialization.cpp
>UnnecessaryValueParamCheck.cpp
>
> Added:
> clang-tools-extra/trunk/clang-tidy/performance/InefficientStringConcatenationCheck.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/performance/InefficientStringConcatenationCheck.cpp?rev=277677=auto
>
> ==
> ---
> clang-tools-extra/trunk/clang-tidy/performance/InefficientStringConcatenationCheck.cpp
> (added)
> +++
> clang-tools-extra/trunk/clang-tidy/performance/InefficientStringConcatenationCheck.cpp
> Wed Aug  3 18:06:03 2016
> @@ -0,0 +1,86 @@
> +//===--- InefficientStringConcatenationCheck.cpp -
> clang-tidy--===//
> +//
> +// The LLVM Compiler Infrastructure
> +//
> +// This file is distributed under the University of Illinois Open Source
> +// License. See LICENSE.TXT for details.
> +//
>
> +//===--===//
> +
> +#include "InefficientStringConcatenationCheck.h"
> +#include "clang/AST/ASTContext.h"
> +#include "clang/ASTMatchers/ASTMatchFinder.h"
> +
> +using namespace clang::ast_matchers;
> +
> +namespace clang {
> +namespace tidy {
> +namespace performance {
> +
> +void InefficientStringConcatenationCheck::storeOptions(
> +ClangTidyOptions::OptionMap ) {
> +  Options.store(Opts, "StrictMode", StrictMode);
> +}
> +
> +InefficientStringConcatenationCheck::InefficientStringConcatenationCheck(
> +StringRef Name, ClangTidyContext *Context)
> +: ClangTidyCheck(Name, Context), StrictMode(Options.get("StrictMode",
> 0)) {}
> +
> +void InefficientStringConcatenationCheck::registerMatchers(
> +MatchFinder *Finder) {
> +  if (!getLangOpts().CPlusPlus)
> +return;
> +
> +  const auto BasicStringType =
> +  hasType(cxxRecordDecl(hasName("::std::basic_string")));
> +
> +  const auto BasicStringPlusOperator = cxxOperatorCallExpr(
> +  hasOverloadedOperatorName("+"),
> +  hasAnyArgument(ignoringImpCasts(declRefExpr(BasicStringType;
> +
> +  const auto PlusOperator =
> +  cxxOperatorCallExpr(
> +  hasOverloadedOperatorName("+"),
> +  hasAnyArgument(ignoringImpCasts(declRefExpr(BasicStringType))),
> +  hasDescendant(BasicStringPlusOperator))
> +  .bind("plusOperator");
> +
> +  const auto AssignOperator = cxxOperatorCallExpr(
> +  hasOverloadedOperatorName("="),
> +  hasArgument(0, declRefExpr(BasicStringType,
> + hasDeclaration(decl().bind("lhsStrT")))
> + .bind("lhsStr")),
> +  hasArgument(1, stmt(hasDescendant(declRefExpr(
> +
>  hasDeclaration(decl(equalsBoundNode("lhsStrT"))),
> +  hasDescendant(BasicStringPlusOperator));
> +
> +  if 

Re: [PATCH] D23130: Add a check for definitions in the global namespace.

2016-08-08 Thread David Blaikie via cfe-commits
This seems to have a lot of overlap with -Wmissing-prototype, really - what
do you think of the overlap/distinction between the two?

On Wed, Aug 3, 2016 at 1:25 PM Eugene Zelenko via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Eugene.Zelenko added a subscriber: Eugene.Zelenko.
> Eugene.Zelenko added a comment.
>
> Please mention this check in docs/ReleaseNotes.rst (in alphabetical order).
>
>
> https://reviews.llvm.org/D23130
>
>
>
> ___
> 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: [PATCH] D22729: MPIBufferDerefCheck for Clang-Tidy

2016-08-08 Thread Haojian Wu via cfe-commits
hokein accepted this revision.
hokein added a comment.
This revision is now accepted and ready to land.

LGTM.


https://reviews.llvm.org/D22729



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


  1   2   >