[PATCH] D41347: [libc++] Lift std::errc into a separated header

2018-04-05 Thread Zhihao Yuan via Phabricator via cfe-commits
lichray updated this revision to Diff 141109.
lichray added a comment.
Herald added a subscriber: christof.

Update module map


Repository:
  rCXX libc++

https://reviews.llvm.org/D41347

Files:
  include/__errc
  include/module.modulemap
  include/system_error

Index: include/system_error
===
--- include/system_error
+++ include/system_error
@@ -120,88 +120,6 @@
 const char* what() const noexcept;
 };
 
-enum class errc
-{
-address_family_not_supported,   // EAFNOSUPPORT
-address_in_use, // EADDRINUSE
-address_not_available,  // EADDRNOTAVAIL
-already_connected,  // EISCONN
-argument_list_too_long, // E2BIG
-argument_out_of_domain, // EDOM
-bad_address,// EFAULT
-bad_file_descriptor,// EBADF
-bad_message,// EBADMSG
-broken_pipe,// EPIPE
-connection_aborted, // ECONNABORTED
-connection_already_in_progress, // EALREADY
-connection_refused, // ECONNREFUSED
-connection_reset,   // ECONNRESET
-cross_device_link,  // EXDEV
-destination_address_required,   // EDESTADDRREQ
-device_or_resource_busy,// EBUSY
-directory_not_empty,// ENOTEMPTY
-executable_format_error,// ENOEXEC
-file_exists,// EEXIST
-file_too_large, // EFBIG
-filename_too_long,  // ENAMETOOLONG
-function_not_supported, // ENOSYS
-host_unreachable,   // EHOSTUNREACH
-identifier_removed, // EIDRM
-illegal_byte_sequence,  // EILSEQ
-inappropriate_io_control_operation, // ENOTTY
-interrupted,// EINTR
-invalid_argument,   // EINVAL
-invalid_seek,   // ESPIPE
-io_error,   // EIO
-is_a_directory, // EISDIR
-message_size,   // EMSGSIZE
-network_down,   // ENETDOWN
-network_reset,  // ENETRESET
-network_unreachable,// ENETUNREACH
-no_buffer_space,// ENOBUFS
-no_child_process,   // ECHILD
-no_link,// ENOLINK
-no_lock_available,  // ENOLCK
-no_message_available,   // ENODATA
-no_message, // ENOMSG
-no_protocol_option, // ENOPROTOOPT
-no_space_on_device, // ENOSPC
-no_stream_resources,// ENOSR
-no_such_device_or_address,  // ENXIO
-no_such_device, // ENODEV
-no_such_file_or_directory,  // ENOENT
-no_such_process,// ESRCH
-not_a_directory,// ENOTDIR
-not_a_socket,   // ENOTSOCK
-not_a_stream,   // ENOSTR
-not_connected,  // ENOTCONN
-not_enough_memory,  // ENOMEM
-not_supported,  // ENOTSUP
-operation_canceled, // ECANCELED
-operation_in_progress,  // EINPROGRESS
-operation_not_permitted,// EPERM
-operation_not_supported,// EOPNOTSUPP
-operation_would_block,  // EWOULDBLOCK
-owner_dead, // EOWNERDEAD
-permission_denied,  // EACCES
-protocol_error, // EPROTO
-protocol_not_supported, // EPROTONOSUPPORT
-read_only_file_system,  // EROFS
-resource_deadlock_would_occur,  // EDEADLK
-resource_unavailable_try_again, // EAGAIN
-result_out_of_range,// ERANGE
-state_not_recoverable,  // ENOTRECOVERABLE
-stream_timeout, // ETIME
-text_file_busy, // ETXTBSY
-timed_out,  // ETIMEDOUT
-too_many_files_open_in_system,  // ENFILE
-too_many_files_open,// EMFILE
-too_many_links, // EMLINK
-too_many_symbolic_link_levels,  // ELOOP
-value_too_large,// EOVERFLOW
-wrong_protocol_type // EPROTOTYPE
-};
-
 template <> struct is_error_condition_enum
 : true_type { }
 
@@ -225,8 +143,7 @@
 
 */
 
-#include <__config>
-#include 
+#include <__errc>
 #include 
 #include 
 #include <__functional_base>
@@ -260,109 +177,6 @@
 _LIBCPP_INLINE_VAR constexpr size_t is_error_condition_enum_v = is_error_condition_enum<_Tp>::value;
 #endif
 
-// Some error codes are not present on all platforms, so we provide e

[PATCH] D41458: [libc++][C++17] Elementary string conversions for integral types

2018-04-05 Thread Zhihao Yuan via Phabricator via cfe-commits
lichray updated this revision to Diff 141110.
lichray added a comment.

Update module map


Repository:
  rCXX libc++

https://reviews.llvm.org/D41458

Files:
  .gitignore
  include/charconv
  include/module.modulemap
  src/charconv.cpp
  test/std/utilities/charconv/
  test/std/utilities/charconv/charconv.from.chars/
  test/std/utilities/charconv/charconv.from.chars/integral.bool.fail.cpp
  test/std/utilities/charconv/charconv.from.chars/integral.pass.cpp
  test/std/utilities/charconv/charconv.to.chars/
  test/std/utilities/charconv/charconv.to.chars/integral.bool.fail.cpp
  test/std/utilities/charconv/charconv.to.chars/integral.pass.cpp
  test/support/charconv_test_helpers.h

Index: test/support/charconv_test_helpers.h
===
--- /dev/null
+++ test/support/charconv_test_helpers.h
@@ -0,0 +1,233 @@
+//===--===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===--===//
+
+#ifndef SUPPORT_CHARCONV_TEST_HELPERS_H
+#define SUPPORT_CHARCONV_TEST_HELPERS_H
+
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "test_macros.h"
+
+using std::false_type;
+using std::true_type;
+
+template 
+constexpr auto
+is_non_narrowing(From a) -> decltype(To{a}, true_type())
+{
+return {};
+}
+
+template 
+constexpr auto
+is_non_narrowing(...) -> false_type
+{
+return {};
+}
+
+template 
+constexpr bool
+_fits_in(T, true_type /* non-narrowing*/, ...)
+{
+return true;
+}
+
+template >
+constexpr bool
+_fits_in(T v, false_type, true_type /* T signed*/, true_type /* X signed */)
+{
+return xl::lowest() <= v && v <= (xl::max)();
+}
+
+template >
+constexpr bool
+_fits_in(T v, false_type, true_type /* T signed */, false_type /* X unsigned*/)
+{
+return 0 <= v && typename std::make_unsigned::type(v) <= (xl::max)();
+}
+
+template >
+constexpr bool
+_fits_in(T v, false_type, false_type /* T unsigned */, ...)
+{
+return v <= typename std::make_unsigned::type((xl::max)());
+}
+
+template 
+constexpr bool
+fits_in(T v)
+{
+return _fits_in(v, is_non_narrowing(v), std::is_signed(),
+   std::is_signed());
+}
+
+template 
+struct to_chars_test_base
+{
+template 
+void test(T v, char const (&expect)[N], Ts... args)
+{
+using std::to_chars;
+std::to_chars_result r;
+
+constexpr size_t len = N - 1;
+static_assert(len > 0, "expected output won't be empty");
+
+if (!fits_in(v))
+return;
+
+r = to_chars(buf, buf + len - 1, X(v), args...);
+assert(r.ptr == buf + len - 1);
+assert(r.ec == std::errc::value_too_large);
+
+r = to_chars(buf, buf + sizeof(buf), X(v), args...);
+assert(r.ptr == buf + len);
+assert(r.ec == std::errc{});
+assert(memcmp(buf, expect, len) == 0);
+}
+
+template 
+void test_value(X v, Ts... args)
+{
+using std::to_chars;
+std::to_chars_result r;
+
+r = to_chars(buf, buf + sizeof(buf), v, args...);
+assert(r.ec == std::errc{});
+*r.ptr = '\0';
+
+auto a = fromchars(buf, r.ptr, args...);
+assert(v == a);
+
+auto ep = r.ptr - 1;
+r = to_chars(buf, ep, v, args...);
+assert(r.ptr == ep);
+assert(r.ec == std::errc::value_too_large);
+}
+
+private:
+using max_t = typename std::conditional::value, long long,
+unsigned long long>::type;
+
+static auto fromchars(char const* p, char const* ep, int base, true_type)
+-> long long
+{
+char* last;
+auto r = strtoll(p, &last, base);
+assert(last == ep);
+
+return r;
+}
+
+static auto fromchars(char const* p, char const* ep, int base, false_type)
+-> unsigned long long
+{
+char* last;
+auto r = strtoull(p, &last, base);
+assert(last == ep);
+
+return r;
+}
+
+static auto fromchars(char const* p, char const* ep, int base = 10) -> max_t
+{
+return fromchars(p, ep, base, std::is_signed());
+}
+
+char buf[100];
+};
+
+template 
+struct roundtrip_test_base
+{
+template 
+void test(T v, Ts... args)
+{
+using std::from_chars;
+using std::to_chars;
+std::from_chars_result r2;
+std::to_chars_result r;
+X x = 0xc;
+
+if (fits_in(v))
+{
+r = to_chars(buf, buf + sizeof(buf), v, args...);
+assert(r.ec == std::errc{});
+
+r2 = from_chars(buf, r.ptr, x, args...);
+assert(r2.ptr == r.ptr);
+assert(x == X(v));
+}
+else
+{
+r = to_chars(buf, buf +

[PATCH] D45004: [clang-format] New style option IndentWrappedObjCMethodNames

2018-04-05 Thread Jacek Olesiak via Phabricator via cfe-commits
jolesiak added a comment.

> I am proposing to update the Google Objective-C style guide to explicitly 
> describe the desired indentation behavior.

+1


Repository:
  rC Clang

https://reviews.llvm.org/D45004



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


[PATCH] D45284: [RISCV] More validations on the input value of -march=

2018-04-05 Thread Alex Bradbury via Phabricator via cfe-commits
asb added a comment.

Based on Andrew's response (thanks Kito for sending the query) it looks like 
GCC accepting lowercase only is intentional, and we should follow that. In 
which case, it might be an improvement to reject uppercase letters in the ISA 
string with a message saying that only lowercase letters are accepted.


https://reviews.llvm.org/D45284



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


[PATCH] D45305: ObjCGNU: Fix empty v3 protocols being emitted two fields short

2018-04-05 Thread David Chisnall via Phabricator via cfe-commits
theraven added a comment.

Looks correct to me.  Protocols are only referenced by pointer, so it doesn't 
matter for old versions of the runtime if these fields are present.


Repository:
  rC Clang

https://reviews.llvm.org/D45305



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


[PATCH] D45004: [clang-format] New style option IndentWrappedObjCMethodNames

2018-04-05 Thread Daniel Jasper via Phabricator via cfe-commits
djasper added a comment.

I still really believe that these config options do no make sense and are 
actively confusing.

I see two options:

- We leave this as is
- We fix this right

The right fix here is (IMO) that a style already is per language and thus 
already has a member specifying the language. What we have done in the scope of 
formatting the contents of raw string literals is that you can, in the same 
configuration file/setting, have different styles based on the language being 
formatted. Thus, if we encounter a text-formatted proto inside a C++ raw string 
literal, we switch to the style flags for proto rather than using those for 
C++. You have these different options in the same style configuration file, in 
a different section per language.

So, if you look at a config file, you could see how a user sets the existing 
IndentWrappedFunctionNames to true for ObjC and to false for C++. Now IMO, that 
should mean that ObjC function names are indented and C++ functions are not, 
even if the language of the *file* is ObjC. It doesn't require us to repeat 
these options for each language in the style for each language.

Getting this right will require some refactoring of how a style is passed 
around and used, but I think it'd be the right thing to do.

Look at it the other way. If we go forward with this patch you can have style 
configuration files saying:

  ---

  BasedOnStyle: LLVM
  ---
  Language: Cpp
  IndentWrappedObjCMethodNames: Never
  IndentWrappedFunctionNames: true
  ---
  Language: ObjC
  IndentWrappedObjCMethodNames: Always
  IndentWrappedFunctionNames: false
  ---

I find it very hard to explain what that even means.


Repository:
  rC Clang

https://reviews.llvm.org/D45004



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


[PATCH] D45311: Introduce wbinvd intrinsic

2018-04-05 Thread Gabor Buella via Phabricator via cfe-commits
GBuella created this revision.
GBuella added reviewers: craig.topper, echristo.
Herald added a subscriber: cfe-commits.

A previously missing intrinsic for an old instruction.


Repository:
  rC Clang

https://reviews.llvm.org/D45311

Files:
  include/clang/Basic/BuiltinsX86.def
  lib/Headers/ia32intrin.h
  test/CodeGen/builtin-wbinvd.c


Index: test/CodeGen/builtin-wbinvd.c
===
--- /dev/null
+++ test/CodeGen/builtin-wbinvd.c
@@ -0,0 +1,10 @@
+// RUN: %clang_cc1 %s -ffreestanding -triple=x86_64-unknown-unknown -emit-llvm 
-o - -Wall -Werror | FileCheck %s
+// RUN: %clang_cc1 %s -ffreestanding -triple=i386-unknown-unknown -emit-llvm 
-o - -Wall -Werror | FileCheck %s
+
+#include 
+
+void test_wbinvd(void) {
+  //CHECK-LABEL: @test_wbinvd
+  //CHECK: @llvm.x86.wbinvd
+  _wbinvd();
+}
Index: lib/Headers/ia32intrin.h
===
--- lib/Headers/ia32intrin.h
+++ lib/Headers/ia32intrin.h
@@ -70,4 +70,9 @@
 
 #define _rdpmc(A) __rdpmc(A)
 
+static __inline__ void __attribute__((__always_inline__, __nodebug__))
+_wbinvd(void) {
+  return __builtin_ia32_wbinvd();
+}
+
 #endif /* __IA32INTRIN_H */
Index: include/clang/Basic/BuiltinsX86.def
===
--- include/clang/Basic/BuiltinsX86.def
+++ include/clang/Basic/BuiltinsX86.def
@@ -679,6 +679,8 @@
 //CLWB
 TARGET_BUILTIN(__builtin_ia32_clwb, "vvC*", "", "clwb")
 
+TARGET_BUILTIN(__builtin_ia32_wbinvd, "v", "", "")
+
 // ADX
 TARGET_BUILTIN(__builtin_ia32_addcarryx_u32, "UcUcUiUiUi*", "", "adx")
 TARGET_BUILTIN(__builtin_ia32_addcarry_u32, "UcUcUiUiUi*", "", "")


Index: test/CodeGen/builtin-wbinvd.c
===
--- /dev/null
+++ test/CodeGen/builtin-wbinvd.c
@@ -0,0 +1,10 @@
+// RUN: %clang_cc1 %s -ffreestanding -triple=x86_64-unknown-unknown -emit-llvm -o - -Wall -Werror | FileCheck %s
+// RUN: %clang_cc1 %s -ffreestanding -triple=i386-unknown-unknown -emit-llvm -o - -Wall -Werror | FileCheck %s
+
+#include 
+
+void test_wbinvd(void) {
+  //CHECK-LABEL: @test_wbinvd
+  //CHECK: @llvm.x86.wbinvd
+  _wbinvd();
+}
Index: lib/Headers/ia32intrin.h
===
--- lib/Headers/ia32intrin.h
+++ lib/Headers/ia32intrin.h
@@ -70,4 +70,9 @@
 
 #define _rdpmc(A) __rdpmc(A)
 
+static __inline__ void __attribute__((__always_inline__, __nodebug__))
+_wbinvd(void) {
+  return __builtin_ia32_wbinvd();
+}
+
 #endif /* __IA32INTRIN_H */
Index: include/clang/Basic/BuiltinsX86.def
===
--- include/clang/Basic/BuiltinsX86.def
+++ include/clang/Basic/BuiltinsX86.def
@@ -679,6 +679,8 @@
 //CLWB
 TARGET_BUILTIN(__builtin_ia32_clwb, "vvC*", "", "clwb")
 
+TARGET_BUILTIN(__builtin_ia32_wbinvd, "v", "", "")
+
 // ADX
 TARGET_BUILTIN(__builtin_ia32_addcarryx_u32, "UcUcUiUiUi*", "", "adx")
 TARGET_BUILTIN(__builtin_ia32_addcarry_u32, "UcUcUiUiUi*", "", "")
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D45152: [MinGW] Add option for disabling looking for a mingw gcc in PATH

2018-04-05 Thread Martin Storsjö via Phabricator via cfe-commits
mstorsjo added a comment.

In https://reviews.llvm.org/D45152#1057787, @martell wrote:

> @mstorsjo I would much prefer to detect the clang sysroot first and if that 
> exists just ignore the gcc one.
>  Most of the time clang and gcc will be in the same bin folder and in the 
> case where the clang sysroot with mingw prefix folders is not found we can 
> just default back to the default gcc behavior.
>  This should cover the use case for existing gcc users while not blocking us 
> to move forward with clang only toolchains.


That's probably an even better idea - I'll give that a try.

> If someone really wants to ignore the clang sysroot with mingw folders we 
> could add a flag for that and not the other way around.
>  What are your thoughts here?

I guess that could be useful in theory, but I'd hold off adding that until 
there's a concrete need for that case (it sounds quite contrieved to me, and 
there's always the `--sysroot=` option).

> Though I do like the idea of having an `--assume-sysroot-bin` as an option 
> for all toolchains

Well ideally all toolchains should use similar logic for finding sysroots, 
except for cases where they by design are different. I haven't looked for how 
many other cases of similar logic there is.


Repository:
  rC Clang

https://reviews.llvm.org/D45152



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


[PATCH] D45311: Introduce wbinvd intrinsic

2018-04-05 Thread Gabor Buella via Phabricator via cfe-commits
GBuella added a comment.

The reason is, the _wbnoinvd intrinsic, and builtin were just recently 
introduced in GCC.


Repository:
  rC Clang

https://reviews.llvm.org/D45311



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


r329263 - [clang-format] Preserve spaces before a percent in (text) protos

2018-04-05 Thread Krasimir Georgiev via cfe-commits
Author: krasimir
Date: Thu Apr  5 02:33:03 2018
New Revision: 329263

URL: http://llvm.org/viewvc/llvm-project?rev=329263&view=rev
Log:
[clang-format] Preserve spaces before a percent in (text) protos

This makes sure that we do not change the meaning of pieces of text with
format specifiers.

Modified:
cfe/trunk/lib/Format/TokenAnnotator.cpp
cfe/trunk/unittests/Format/FormatTestProto.cpp
cfe/trunk/unittests/Format/FormatTestTextProto.cpp

Modified: cfe/trunk/lib/Format/TokenAnnotator.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/TokenAnnotator.cpp?rev=329263&r1=329262&r2=329263&view=diff
==
--- cfe/trunk/lib/Format/TokenAnnotator.cpp (original)
+++ cfe/trunk/lib/Format/TokenAnnotator.cpp Thu Apr  5 02:33:03 2018
@@ -2518,6 +2518,10 @@ bool TokenAnnotator::spaceRequiredBefore
 // A percent is probably part of a formatting specification, such as %lld.
 if (Left.is(tok::percent))
   return false;
+// Preserve the existence of a space before a percent for cases like 0x%04x
+// and "%d %d"
+if (Left.is(tok::numeric_constant) && Right.is(tok::percent))
+  return Right.WhitespaceRange.getEnd() != 
Right.WhitespaceRange.getBegin();
   } else if (Style.Language == FormatStyle::LK_JavaScript) {
 if (Left.is(TT_JsFatArrow))
   return true;

Modified: cfe/trunk/unittests/Format/FormatTestProto.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTestProto.cpp?rev=329263&r1=329262&r2=329263&view=diff
==
--- cfe/trunk/unittests/Format/FormatTestProto.cpp (original)
+++ cfe/trunk/unittests/Format/FormatTestProto.cpp Thu Apr  5 02:33:03 2018
@@ -442,9 +442,11 @@ TEST_F(FormatTestProto, FormatsOptionsEx
"};");
 }
 
-TEST_F(FormatTestProto, NoSpaceAfterPercent) {
+TEST_F(FormatTestProto, SpacesAroundPercents) {
   verifyFormat("option (MyProto.options) = {\n"
"  key: %lld\n"
+   "  key: 0x%04x\n"
+   "  key: \"%d %d\"\n"
"};");
 }
 

Modified: cfe/trunk/unittests/Format/FormatTestTextProto.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTestTextProto.cpp?rev=329263&r1=329262&r2=329263&view=diff
==
--- cfe/trunk/unittests/Format/FormatTestTextProto.cpp (original)
+++ cfe/trunk/unittests/Format/FormatTestTextProto.cpp Thu Apr  5 02:33:03 2018
@@ -419,8 +419,10 @@ TEST_F(FormatTestTextProto, FormatsExten
   "}");
 }
 
-TEST_F(FormatTestTextProto, NoSpaceAfterPercent) {
+TEST_F(FormatTestTextProto, SpacesAroundPercents) {
   verifyFormat("key: %d");
+  verifyFormat("key: 0x%04x");
+  verifyFormat("key: \"%d %d\"");
 }
 
 TEST_F(FormatTestTextProto, FormatsRepeatedListInitializers) {


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


[PATCH] D44996: [clang-format] Ensure ObjC selectors with 0 args are annotated correctly

2018-04-05 Thread Daniel Jasper via Phabricator via cfe-commits
djasper accepted this revision.
djasper added inline comments.



Comment at: lib/Format/TokenAnnotator.cpp:1347
+} else if (Current.isOneOf(tok::identifier, tok::kw_new) &&
+   Current.Previous && Current.Previous->is(TT_CastRParen) &&
+   Current.Previous->MatchingParen &&

benhamilton wrote:
> benhamilton wrote:
> > djasper wrote:
> > > Isn't it wrong that we detect this as a cast r_paren in the first place?
> > Fantastic question, I asked myself the same thing.
> > 
> > I tried a few variations on this (leaving it as `TT_Unknown`, making a new 
> > type, etc.) and discovered there is at least one existing place which 
> > relies on the `TT_CastRParen` type as an indicator of ObjC code. Example:
> > 
> > https://github.com/llvm-mirror/clang/blob/e37a191e99773959118155304ec2ed0bc0d591c2/lib/Format/TokenAnnotator.cpp#L394
> > 
> > I can fix those, but if I do so, I think it should be a separate diff. What 
> > do you think?
> @djasper and I talked about this on Friday and agreed we should follow up 
> separately.
> 
> I filed https://bugs.llvm.org/show_bug.cgi?id=36976 to follow up.
You might also want to add a

  // FIXME: ...


Repository:
  rC Clang

https://reviews.llvm.org/D44996



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


[PATCH] D45094: [LibTooling] Make interface of VFS injection into ClangTool more user-friendly

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

Thanks, this patch raises a very good point. Having a VFS that is not overlayed 
over RealFS is almost always the wrong thing to do.
On the other hand, I think it's useful to have the client code mention that it 
overlays over real filesystem, rather than relying on magic inside ClangTool.

I suggest we add a comment hinting that vfs you pass should be overlayed over 
the real filesystem, unless the client code knows what it's doing.
And provide an easy-to-use helper function to do that.

  /// Creates overlayed file system with RealFS at the lowest priority and \p 
FS after that.
  IntrusiveRefCntPtr 
overlayRealFs(IntrusiveRefCntPtr FS);
  
  // .
  
  /// \param FileSystem . 
  /// Don't pass a vfs that is not overlayed over the RealFS unless you 
know what you're doing. 
  /// Use overlayRealFS helper to easily add the RealFS overlay.




Comment at: include/clang/Tooling/Tooling.h:299
 public:
-  /// \brief Constructs a clang tool to run over a list of files.
+  /// \brief Constructs a Clang tool to run over a list of files.
   ///

The convention in this file seems to be not to capitalize the terms, unless 
they are class names.
E.g. "ClangTool" is capitalized, but "clang tool" is not.
Maybe leave the comment as is?


Repository:
  rC Clang

https://reviews.llvm.org/D45094



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


[PATCH] D45285: [clangd-vscode] Update VScode dependencies

2018-04-05 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov accepted this revision.
ilya-biryukov added a reviewer: ilya-biryukov.
ilya-biryukov added a comment.

LGTM


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D45285



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


[PATCH] D44203: [clang-format] Improve Incomplete detection for (text) protos

2018-04-05 Thread Krasimir Georgiev via Phabricator via cfe-commits
krasimir updated this revision to Diff 141121.
krasimir marked 2 inline comments as done.
krasimir added a comment.

- Address review comments


Repository:
  rC Clang

https://reviews.llvm.org/D44203

Files:
  lib/Format/TokenAnnotator.cpp
  unittests/Format/FormatTestProto.cpp
  unittests/Format/FormatTestTextProto.cpp

Index: unittests/Format/FormatTestTextProto.cpp
===
--- unittests/Format/FormatTestTextProto.cpp
+++ unittests/Format/FormatTestTextProto.cpp
@@ -19,12 +19,22 @@
 
 class FormatTestTextProto : public ::testing::Test {
 protected:
+  enum StatusCheck { SC_ExpectComplete, SC_ExpectIncomplete, SC_DoNotCheck };
+
   static std::string format(llvm::StringRef Code, unsigned Offset,
-unsigned Length, const FormatStyle &Style) {
+unsigned Length, const FormatStyle &Style,
+StatusCheck CheckComplete = SC_ExpectComplete) {
 DEBUG(llvm::errs() << "---\n");
 DEBUG(llvm::errs() << Code << "\n\n");
 std::vector Ranges(1, tooling::Range(Offset, Length));
-tooling::Replacements Replaces = reformat(Style, Code, Ranges);
+FormattingAttemptStatus Status;
+tooling::Replacements Replaces =
+reformat(Style, Code, Ranges, "", &Status);
+if (CheckComplete != SC_DoNotCheck) {
+  bool ExpectedCompleteFormat = CheckComplete == SC_ExpectComplete;
+  EXPECT_EQ(ExpectedCompleteFormat, Status.FormatComplete)
+  << Code << "\n\n";
+}
 auto Result = applyAllReplacements(Code, Replaces);
 EXPECT_TRUE(static_cast(Result));
 DEBUG(llvm::errs() << "\n" << *Result << "\n\n");
@@ -44,6 +54,12 @@
 Style.ColumnLimit = 60; // To make writing tests easier.
 verifyFormat(Code, Style);
   }
+
+  static void verifyIncompleteFormat(llvm::StringRef Code) {
+FormatStyle Style = getGoogleStyle(FormatStyle::LK_TextProto);
+EXPECT_EQ(Code.str(),
+  format(Code, 0, Code.size(), Style, SC_ExpectIncomplete));
+  }
 };
 
 TEST_F(FormatTestTextProto, KeepsTopLevelEntriesFittingALine) {
@@ -452,5 +468,39 @@
"  >\n"
">");
 }
+
+TEST_F(FormatTestTextProto, IncompleteFormat) {
+  verifyIncompleteFormat("data {");
+  verifyIncompleteFormat("data <");
+  verifyIncompleteFormat("data [");
+  verifyIncompleteFormat("data: {");
+  verifyIncompleteFormat("data: <");
+  verifyIncompleteFormat("data: [");
+  verifyIncompleteFormat("key:");
+  verifyIncompleteFormat("key:}");
+  verifyIncompleteFormat("key: ]");
+  verifyIncompleteFormat("key: >");
+  verifyIncompleteFormat(": value");
+  verifyIncompleteFormat(": {}");
+  verifyIncompleteFormat(": <>");
+  verifyIncompleteFormat(": []");
+  verifyIncompleteFormat("}\n"
+ "key: value");
+  verifyIncompleteFormat("]\n"
+ "key: value");
+  verifyIncompleteFormat("> key: value");
+  verifyIncompleteFormat("data { key: {");
+  verifyIncompleteFormat("data < key: [");
+  verifyIncompleteFormat("data [ key: {");
+  verifyIncompleteFormat("> key: value {");
+  verifyIncompleteFormat("> key: [");
+  verifyIncompleteFormat("}\n"
+ "key: {");
+  verifyIncompleteFormat("data { key: 1 id:");
+  verifyIncompleteFormat("}\n"
+ "key {");
+  verifyIncompleteFormat("> <");
+}
+
 } // end namespace tooling
 } // end namespace clang
Index: unittests/Format/FormatTestProto.cpp
===
--- unittests/Format/FormatTestProto.cpp
+++ unittests/Format/FormatTestProto.cpp
@@ -18,13 +18,23 @@
 namespace format {
 
 class FormatTestProto : public ::testing::Test {
+  enum StatusCheck { SC_ExpectComplete, SC_ExpectIncomplete, SC_DoNotCheck };
+
 protected:
   static std::string format(llvm::StringRef Code, unsigned Offset,
-unsigned Length, const FormatStyle &Style) {
+unsigned Length, const FormatStyle &Style,
+StatusCheck CheckComplete = SC_ExpectComplete) {
 DEBUG(llvm::errs() << "---\n");
 DEBUG(llvm::errs() << Code << "\n\n");
 std::vector Ranges(1, tooling::Range(Offset, Length));
-tooling::Replacements Replaces = reformat(Style, Code, Ranges);
+FormattingAttemptStatus Status;
+tooling::Replacements Replaces =
+reformat(Style, Code, Ranges, "", &Status);
+if (CheckComplete != SC_DoNotCheck) {
+  bool ExpectedCompleteFormat = CheckComplete == SC_ExpectComplete;
+  EXPECT_EQ(ExpectedCompleteFormat, Status.FormatComplete)
+  << Code << "\n\n";
+}
 auto Result = applyAllReplacements(Code, Replaces);
 EXPECT_TRUE(static_cast(Result));
 DEBUG(llvm::errs() << "\n" << *Result << "\n\n");
@@ -40,6 +50,12 @@
   static void verifyFormat(llvm::StringRef Code) {
 EXPECT_EQ(Code.str(), format(test::messUp(Code)));
   }
+
+  static void verifyIncompleteFormat(llvm::Str

[PATCH] D44203: [clang-format] Improve Incomplete detection for (text) protos

2018-04-05 Thread Krasimir Georgiev via Phabricator via cfe-commits
krasimir added inline comments.



Comment at: lib/Format/TokenAnnotator.cpp:665
   }
+  if ((Style.Language == FormatStyle::LK_Proto ||
+   Style.Language == FormatStyle::LK_TextProto) &&

sammccall wrote:
> I don't really understand what this is doing.
> It seems to be detecting some particular sequence of invalid tokens 
> `}:`,`]:`,`>:`. Why are these special? 
> 
> What's the contract of consumeToken()? It's hard to see from the callsites.
Thank you very much! I guess I got carried away. These don't make sense. I'll 
update it to only keep dangling `:` as in `key:`.

Returning false from consumeToken has the desired effect that (eventually) 
marks the line as incomplete here:
https://github.com/llvm-mirror/clang/blob/master/lib/Format/TokenAnnotator.cpp#L1055



Comment at: lib/Format/TokenAnnotator.cpp:773
 case tok::r_brace:
-  // Lines can start with '}'.
-  if (Tok->Previous)
+  // Lines can start with '}' except in text protos.
+  if (Tok->Previous || Style.Language == FormatStyle::LK_TextProto)

sammccall wrote:
> In what sense of "line" is this true?
This is the UnwrappedLine concept of clang-format: roughly a maximal sequence 
of tokens that we could have put on the same line if there was no column limit.


Repository:
  rC Clang

https://reviews.llvm.org/D44203



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


[PATCH] D44888: [RISCV] Default enable linker relaxation and add -mrelax, -mno-relax flags

2018-04-05 Thread Alex Bradbury via Phabricator via cfe-commits
asb added a comment.

Could you please add a test? Given that the current version of 
https://reviews.llvm.org/D44886 enables linker relaxation by default in the 
backend, shouldn't -mno-relax cause -relax to be set?


Repository:
  rC Clang

https://reviews.llvm.org/D44888



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


[PATCH] D44888: [RISCV] Default enable linker relaxation and add -mrelax, -mno-relax flags

2018-04-05 Thread Alex Bradbury via Phabricator via cfe-commits
asb added a comment.

In https://reviews.llvm.org/D44888#1058257, @asb wrote:

> Could you please add a test? Given that the current version of 
> https://reviews.llvm.org/D44886 enables linker relaxation by default in the 
> backend, shouldn't -mno-relax cause -relax to be set?


Sorry, I misready D444886. Still, we should do Features.push_back("-relax") at 
least in the case where -mno-relax is given explicitly, meaning we don't have 
to rely on the backend default.


Repository:
  rC Clang

https://reviews.llvm.org/D44888



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


[PATCH] D44226: [clangd] Add -log-lsp-to-stderr option

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



Comment at: clangd/ClangdLSPServer.cpp:412
+llvm::raw_string_ostream OS(Message);
+OS << "method not found (" << Method << ")";
+replyError(ErrorCode::MethodNotFound, OS.str());

simark wrote:
> ilya-biryukov wrote:
> > simark wrote:
> > > simark wrote:
> > > > ilya-biryukov wrote:
> > > > > malaperle wrote:
> > > > > > simark wrote:
> > > > > > > ilya-biryukov wrote:
> > > > > > > > Could we also `log` (i.e. not `vlog`) names of the methods that 
> > > > > > > > were handled successfully? To have some context when something 
> > > > > > > > crashes and we only have non-verbose logs.
> > > > > > > That would be against the purpose of this patch, which is to 
> > > > > > > output nothing if everything goes right (so it's easier to notice 
> > > > > > > when something goes wrong).  Just outputting the names of the 
> > > > > > > methods that are handled successfully would still be very verbose 
> > > > > > > I think.
> > > > > > Wouldn't that mean pretty much logging everything coming in? The 
> > > > > > idea of this patch it to make it that by default Clangd is not 
> > > > > > talkative unless there is an error and optionally make it verbose, 
> > > > > > for troubleshooting.
> > > > > Logs are also useful to diagnose problems in case something crashes 
> > > > > or works incorrectly.
> > > > > Clang will probably log something when processing any request anyway, 
> > > > > logging the method name first will merely give some more context on 
> > > > > which request other log messages correspond to.
> > > > > 
> > > > > > The idea of this patch it to make it that by default Clangd is not 
> > > > > > talkative unless there is an error.
> > > > > I don't think we use logging this way in clangd. Logs give us a way 
> > > > > to make sense of what's happening inside clangd even when there's no 
> > > > > error. `vlog` lets us turn off some extremely noisy output that is 
> > > > > not useful most of the time.
> > > > > We have a whole bunch of log statements that don't correspond to 
> > > > > errors (e.g. "reusing preamble", "building file with compile 
> > > > > command").
> > > > > Logs are also useful to diagnose problems in case something crashes 
> > > > > or works incorrectly.
> > > > Clang will probably log something when processing any request anyway, 
> > > > logging the method name first will merely give some more context on 
> > > > which request other log messages correspond to.
> > > > 
> > > > I think it's fine if clangd logs warning/errors by default, that a user 
> > > > might want to look at and address.  But logging things that happen 
> > > > recurrently and are part of clangd's normal operation just flood the 
> > > > terminal (and makes it harder to spot actual errors).
> > > > 
> > > > I agree that having some context helps to make sense of an error.  A 
> > > > reasonnable way would be to include the method name only when printing 
> > > > an error.  For example, `While handling method 'workspace/symbol': 
> > > > Could not open file foo.`.  That would require us to carry around some 
> > > > more context information, but I think it would be better than printing 
> > > > all the handled methods. 
> > > > 
> > > > > I don't think we use logging this way in clangd. Logs give us a way 
> > > > > to make sense of what's happening inside clangd even when there's no 
> > > > > error. 
> > > > 
> > > > In that case you turn on a more verbose log level.
> > > > 
> > > > > vlog lets us turn off some extremely noisy output that is not useful 
> > > > > most of the time. We have a whole bunch of log statements that don't 
> > > > > correspond to errors (e.g. "reusing preamble", "building file with 
> > > > > compile command").
> > > > 
> > > > I would consider everything that happens at each json-rpc request to be 
> > > > "noisy".  When using clangd from an IDE, there's quite a lot of 
> > > > requests being done.  I was also thinking of modyfing the patch to also 
> > > > use vlog for the "reusing preamble" and "building file with compile 
> > > > command" messages.
> > > One more thing: when using multiple workers and the asynchronous model, 
> > > the error may not be related to the last printed method name:
> > > 
> > > ```
> > > Handling json-rpc method A
> > > Handling json-rpc method B
> > > Some error related to the handling of request A
> > > ```
> > > 
> > > If you just see the error like this, you would think it's cause by 
> > > request B, even though it's when handling request A.  Passing some 
> > > context to the callback would allow us to print the request which is 
> > > really at the origin of the error, avoiding any confusion.  And it would 
> > > allow us to not print it if everything goes fine.
> > clangd logs were never designed to fire only on errors. I probably misread 
> > the patch initially, are you trying to change `log`  into something used 
> > only for logging errors?
> > Could you 

[PATCH] D33844: [clang-tidy] terminating continue check

2018-04-05 Thread Alexander Kornienko via Phabricator via cfe-commits
alexfh added a comment.

Please move the check to bugprone- module. clang-tidy/rename_check.py script 
should do most of the job (you'll have to remove the unnecessary "renamed check 
..." entry in the release notes).




Comment at: clang-tidy/misc/TerminatingContinueCheck.cpp:27
+ equalsBoundNode("closestLoop"))
+  .bind("doWithFalseCond");
+

The "doWithFalseCond" binding isn't used and can be removed.



Comment at: clang-tidy/misc/TerminatingContinueCheck.cpp:30-33
+  continueStmt(anyOf(hasAncestor(forStmt().bind("closestLoop")),
+ hasAncestor(cxxForRangeStmt().bind("closestLoop")),
+ hasAncestor(whileStmt().bind("closestLoop")),
+ hasAncestor(doStmt().bind("closestLoop"))),

Can we avoid repeated traversal of ancestors by inverting the order of matchers 
here? E.g.

  continueStmt(hasAncestor(stmt(anyOf(forStmt(), whileStmt(), 
...)).bind("closestLoop")), hasAncestor(doWithFalse))




Comment at: clang-tidy/misc/TerminatingContinueCheck.cpp:45
+   "'continue' in loop with false condition is equivalent to 'break'");
+  Diag << FixItHint::CreateReplacement(ContStmt->getSourceRange(), "break");
+}

The variable doesn't make the code any better, please remove it. The creation 
of the replacement could be formulated a bit more succint: 
`tooling::fixit::createReplacement(ContStmt, "break");`



Comment at: docs/clang-tidy/checks/misc-terminating-continue.rst:12-21
+  Parser::TPResult Parser::TryParseProtocolQualifiers() {
+assert(Tok.is(tok::less) && "Expected '<' for qualifier list");
+ConsumeToken();
+do {
+  if (Tok.isNot(tok::identifier))
+return TPResult::Error;
+  ConsumeToken();

Quoting a whole method from Clang isn't necessary for the purpose of this 
documentation. I'd go with a simpler example.


https://reviews.llvm.org/D33844



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


[PATCH] D40937: [clang-tidy] Infinite loop checker

2018-04-05 Thread Peter Szecsi via Phabricator via cfe-commits
szepet updated this revision to Diff 141132.
szepet marked 3 inline comments as done.
szepet added a comment.

Removed to bugprone category,
skipping memberExpr cases for now in order to avoid false positives,
other small changes based on review comments.


https://reviews.llvm.org/D40937

Files:
  clang-tidy/bugprone/BugproneTidyModule.cpp
  clang-tidy/bugprone/CMakeLists.txt
  clang-tidy/bugprone/InfiniteLoopCheck.cpp
  clang-tidy/bugprone/InfiniteLoopCheck.h
  docs/ReleaseNotes.rst
  docs/clang-tidy/checks/bugprone-infinite-loop.rst
  docs/clang-tidy/checks/list.rst
  test/clang-tidy/bugprone-infinite-loop.cpp

Index: test/clang-tidy/bugprone-infinite-loop.cpp
===
--- /dev/null
+++ test/clang-tidy/bugprone-infinite-loop.cpp
@@ -0,0 +1,121 @@
+// RUN: %check_clang_tidy %s bugprone-infinite-loop %t
+
+void simple_infinite_loop1() {
+  int i = 0;
+  int j = 0;
+  while (i < 10) {
+// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: The condition variable (i) is not updated in the loop body [bugprone-infinite-loop]
+j++;
+  }
+
+  do {
+// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: The condition variable (i) is not updated in the loop body
+j++;
+  } while (i < 10);
+
+  for (i = 0; i < 10; ++j) {
+// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: The condition variable (i) is not updated in the loop body
+  }
+}
+
+void simple_infinite_loop2() {
+  int i = 0;
+  int j = 0;
+  int Limit = 10;
+  while (i < Limit) {
+// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: None of the condition variables (i, Limit) are updated in the loop body [bugprone-infinite-loop]
+j++;
+  }
+
+  do {
+// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: None of the condition variables (i, Limit) are updated in the loop body
+j++;
+  } while (i < Limit);
+
+  for (i = 0; i < Limit; ++j) {
+// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: None of the condition variables (i, Limit) are updated in the loop body
+  }
+}
+
+void simple_not_infinite() {
+  int i = 0;
+  int Limit = 100;
+  while (i < Limit) { // Not an error since 'Limit' is updated
+Limit--;
+  }
+  do {
+Limit--;
+  } while (i < Limit);
+
+  for (i = 0; i < Limit; Limit--) {
+  }
+}
+
+void escape_before1() {
+  int i = 0;
+  int Limit = 100;
+  int *p = &i;
+  while (i < Limit) { // Not an error, since p is alias of i.
+*++p;
+  }
+
+  do {
+*++p;
+  } while (i < Limit);
+
+  for (i = 0; i < Limit; *++p) {
+;
+  }
+}
+
+void escape_before2() {
+  int i = 0;
+  int Limit = 100;
+  int *p = &i;
+  while (i < Limit) { // We do not warn since the var 'i' is escaped but it is
+  // an actual error, since the pointer 'p' is increased.
+*(p++);
+  }
+}
+
+void escape_after() {
+  int i = 0;
+  int j = 0;
+  int Limit = 10;
+
+  while (i < Limit) {
+// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: None of the condition variables (i, Limit) are updated in the loop body
+  }
+  int *p = &i;
+}
+
+int glob;
+void glob_var(int &x) {
+  int i = 0, Limit = 100;
+  while (x < Limit) { // Not an error since 'x' can be an alias of glob.
+glob++;
+  }
+}
+
+void glob_var2() {
+  int i = 0, Limit = 100;
+  while (glob < Limit) { // Since 'glob' is declared out of the function we do not warn.
+i++;
+  }
+}
+
+struct X {
+  void memberExpr_test(int i) {
+while(i < m) { // False negative: No warning, since skipping the case where
+   // a memberExpr can be found in the condition.
+  ;
+}
+  }
+
+  void memberExpr_test2(int i) {
+while(i < m) {
+  --m;
+}
+  }
+  int m;
+};
Index: docs/clang-tidy/checks/list.rst
===
--- docs/clang-tidy/checks/list.rst
+++ docs/clang-tidy/checks/list.rst
@@ -28,6 +28,7 @@
bugprone-forwarding-reference-overload
bugprone-inaccurate-erase
bugprone-incorrect-roundings
+   bugprone-infinite-loop
bugprone-integer-division
bugprone-lambda-function-name
bugprone-macro-parentheses
Index: docs/clang-tidy/checks/bugprone-infinite-loop.rst
===
--- /dev/null
+++ docs/clang-tidy/checks/bugprone-infinite-loop.rst
@@ -0,0 +1,30 @@
+.. title:: clang-tidy - bugprone-infinite-loop
+
+bugprone-infinite-loop
+==
+
+Finds loops where none of the condition variables are updated in the body. This
+performs a very conservative check in order to avoid false positives and work
+only on integer types at the moment.
+
+Examples:
+
+.. code-block:: c++
+
+  void simple_infinite_loop() {
+int i = 0;
+int j = 0;
+int Limit = 10;
+while (i < Limit) { // Error, since none of the variables are updated.
+  j++;
+}
+  }
+
+  void escape_before() {
+int i = 0;
+int Limit = 100;
+int *p = &i;
+while (i < Limit) { // Not an error, since p is alias of i.
+  *++p;
+}
+  }
Index: docs/ReleaseNotes.rst
===

[PATCH] D40937: [clang-tidy] Infinite loop checker

2018-04-05 Thread Peter Szecsi via Phabricator via cfe-commits
szepet added inline comments.



Comment at: clang-tidy/misc/InfiniteLoopCheck.cpp:121
+
+  Stmt *FunctionBody = nullptr;
+  if (ContainingLambda)

xazax.hun wrote:
> This could be pointer to const, right?
Since the createSequence uses it as a parameter for buildCFG which expects a 
Stmt*, I believe this is fine. (Or I could const cast is away on the call)


https://reviews.llvm.org/D40937



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


[PATCH] D44727: [RISCV] Extend getTargetDefines for RISCVTargetInfo

2018-04-05 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC329278: [PATCH] [RISCV] Extend getTargetDefines for 
RISCVTargetInfo (authored by shiva, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D44727?vs=140959&id=141140#toc

Repository:
  rC Clang

https://reviews.llvm.org/D44727

Files:
  lib/Basic/Targets/RISCV.cpp
  lib/Basic/Targets/RISCV.h
  test/Modules/Inputs/module.map
  test/Modules/target-features.m
  test/Preprocessor/riscv-target-features.c

Index: test/Preprocessor/riscv-target-features.c
===
--- test/Preprocessor/riscv-target-features.c
+++ test/Preprocessor/riscv-target-features.c
@@ -0,0 +1,49 @@
+// RUN: %clang -target riscv32-unknown-linux-gnu -march=rv32i -x c -E -dM %s \
+// RUN: -o - | FileCheck %s
+// RUN: %clang -target riscv64-unknown-linux-gnu -march=rv64i -x c -E -dM %s \
+// RUN: -o - | FileCheck %s
+
+// CHECK-NOT: __riscv_div
+// CHECK-NOT: __riscv_mul
+// CHECK-NOT: __riscv_muldiv
+// CHECK-NOT: __riscv_compressed
+// CHECK-NOT: __riscv_flen
+// CHECK-NOT: __riscv_fdiv
+// CHECK-NOT: __riscv_fsqrt
+// CHECK-NOT: __riscv_atomic
+
+// RUN: %clang -target riscv32-unknown-linux-gnu -march=rv32im -x c -E -dM %s \
+// RUN: -o - | FileCheck --check-prefix=CHECK-M-EXT %s
+// RUN: %clang -target riscv64-unknown-linux-gnu -march=rv64im -x c -E -dM %s \
+// RUN: -o - | FileCheck --check-prefix=CHECK-M-EXT %s
+// CHECK-M-EXT: __riscv_div 1
+// CHECK-M-EXT: __riscv_mul 1
+// CHECK-M-EXT: __riscv_muldiv 1
+
+// RUN: %clang -target riscv32-unknown-linux-gnu -march=rv32ia -x c -E -dM %s \
+// RUN: -o - | FileCheck --check-prefix=CHECK-A-EXT %s
+// RUN: %clang -target riscv64-unknown-linux-gnu -march=rv64ia -x c -E -dM %s \
+// RUN: -o - | FileCheck --check-prefix=CHECK-A-EXT %s
+// CHECK-A-EXT: __riscv_atomic 1
+
+// RUN: %clang -target riscv32-unknown-linux-gnu -march=rv32if -x c -E -dM %s \
+// RUN: -o - | FileCheck --check-prefix=CHECK-F-EXT %s
+// RUN: %clang -target riscv64-unknown-linux-gnu -march=rv64if -x c -E -dM %s \
+// RUN: -o - | FileCheck --check-prefix=CHECK-F-EXT %s
+// CHECK-F-EXT: __riscv_fdiv 1
+// CHECK-F-EXT: __riscv_flen 32
+// CHECK-F-EXT: __riscv_fsqrt 1
+
+// RUN: %clang -target riscv32-unknown-linux-gnu -march=rv32ifd -x c -E -dM %s \
+// RUN: -o - | FileCheck --check-prefix=CHECK-D-EXT %s
+// RUN: %clang -target riscv64-unknown-linux-gnu -march=rv64ifd -x c -E -dM %s \
+// RUN: -o - | FileCheck --check-prefix=CHECK-D-EXT %s
+// CHECK-D-EXT: __riscv_fdiv 1
+// CHECK-D-EXT: __riscv_flen 64
+// CHECK-D-EXT: __riscv_fsqrt 1
+
+// RUN: %clang -target riscv32-unknown-linux-gnu -march=rv32ic -x c -E -dM %s \
+// RUN: -o - | FileCheck --check-prefix=CHECK-C-EXT %s
+// RUN: %clang -target riscv64-unknown-linux-gnu -march=rv64ic -x c -E -dM %s \
+// RUN: -o - | FileCheck --check-prefix=CHECK-C-EXT %s
+// CHECK-C-EXT: __riscv_compressed 1
Index: test/Modules/target-features.m
===
--- test/Modules/target-features.m
+++ test/Modules/target-features.m
@@ -1,6 +1,7 @@
 // REQUIRES: x86-registered-target
 // REQUIRES: arm-registered-target
 // REQUIRES: aarch64-registered-target
+// REQUIRES: riscv-registered-target
 
 // RUN: rm -rf %t
 
@@ -17,45 +18,84 @@
 // RUN: FileCheck %s -check-prefix=X86_32 < %t.x86_32
 // RUN: not %clang_cc1 -triple x86_64-unknown-unknown -fmodules -fmodules-cache-path=%t -fimplicit-module-maps -I %S/Inputs -fsyntax-only  %s 2> %t.x86_64
 // RUN: FileCheck %s -check-prefix=X86_64 < %t.x86_64
+// RUN: not %clang_cc1 -triple riscv32-unknown-unknown -fmodules -fmodules-cache-path=%t -fimplicit-module-maps -I %S/Inputs -fsyntax-only  %s 2> %t.riscv32
+// RUN: FileCheck %s -check-prefix=RISCV32 < %t.riscv32
+// RUN: not %clang_cc1 -triple riscv64-unknown-unknown -fmodules -fmodules-cache-path=%t -fimplicit-module-maps -I %S/Inputs -fsyntax-only  %s 2> %t.riscv64
+// RUN: FileCheck %s -check-prefix=RISCV64 < %t.riscv64
 
 #ifndef SANITY_CHECK
 @import TargetFeatures;
 // AARCH32-NOT: module 'TargetFeatures' requires
 // AARCH64-NOT: module 'TargetFeatures' requires
 // X86_32-NOT: module 'TargetFeatures' requires
 // X86_64-NOT: module 'TargetFeatures' requires
+// RISCV32-NOT: module 'TargetFeatures' requires
+// RISCV64-NOT: module 'TargetFeatures' requires
 @import TargetFeatures.arm;
 // AARCH32-NOT: module 'TargetFeatures.arm' requires
 // AARCH64-NOT: module 'TargetFeatures.arm' requires
 // X86_32: module 'TargetFeatures.arm' requires feature 'arm'
 // X86_64: module 'TargetFeatures.arm' requires feature 'arm'
+// RISCV32: module 'TargetFeatures.arm' requires
+// RISCV64: module 'TargetFeatures.arm' requires
 @import TargetFeatures.arm.aarch32;
 // AARCH32-NOT: module 'TargetFeatures.arm.aarch32' requires
 // AARCH64: module 'TargetFeatures.arm.aarch32' requires feature 'aarch32'
 // X86_32: module 'TargetFeatures.arm.aarch32' requires feature 
 // X86_64: module 'Target

[PATCH] D33537: [clang-tidy] Exception Escape Checker

2018-04-05 Thread Alexander Kornienko via Phabricator via cfe-commits
alexfh requested changes to this revision.
alexfh added inline comments.
This revision now requires changes to proceed.



Comment at: clang-tidy/bugprone/ExceptionEscapeCheck.cpp:100
+
+namespace {
+

> make anonymous namespaces as small as possible, and only use them for class 
> declarations

http://llvm.org/docs/CodingStandards.html#anonymous-namespaces



Comment at: clang-tidy/bugprone/ExceptionEscapeCheck.cpp:105
+const TypeVec throwsException(const FunctionDecl *Func) {
+  static thread_local llvm::SmallSet CallStack;
+

I don't think this is a good use case for a static local variable. If this 
function needs a state, either pass it from the caller or create a utility 
class/struct for it. You can leave a non-recursive entry point with the current 
interface, if you like. For example:

  const TypeVec throwsException(const FunctionDecl *Func, llvm::SmallSet *CallStack) { ... }

  const TypeVec throwsException(const FunctionDecl *Func) {
llvm::SmallSet CallStack;
return throwsException(Func, &CallStack);
  }
  



Comment at: clang-tidy/bugprone/ExceptionEscapeCheck.cpp:110
+
+  if (const auto *Body = Func->getBody()) {
+CallStack.insert(Func);

Please use the concrete type here, since it's not obvious from the context.



Comment at: clang-tidy/bugprone/ExceptionEscapeCheck.cpp:119
+  if (const auto *FPT = Func->getType()->getAs()) {
+for (const auto Ex : FPT->exceptions()) {
+  Result.push_back(&*Ex);

Please use the concrete type here.



Comment at: clang-tidy/bugprone/ExceptionEscapeCheck.cpp:120
+for (const auto Ex : FPT->exceptions()) {
+  Result.push_back(&*Ex);
+}

Ex.getTypePtrOrNull() / Ex.getTypePtr() would be easier to understand here.



Comment at: clang-tidy/bugprone/ExceptionEscapeCheck.cpp:150
+  } else if (const auto *Try = dyn_cast(St)) {
+auto Uncaught = throwsException(Try->getTryBlock(), Caught);
+for (unsigned i = 0; i < Try->getNumHandlers(); ++i) {

Please use the concrete type here and below. 
http://llvm.org/docs/CodingStandards.html#use-auto-type-deduction-to-make-code-more-readable
 says 

> Don’t “almost always” use auto, but do use auto with initializers like 
> cast(...) or other places where the type is already obvious from the 
> context.



Comment at: clang-tidy/bugprone/ExceptionEscapeCheck.cpp:166
+}
+auto *NewEnd = std::remove_if(Uncaught.begin(), Uncaught.end(),
+  [&CaughtType](const Type *ThrownType) {

1. iterator being a pointer is an implementation detail of SmallVector
2. use llvm::remove_if, it has a range based interface



Comment at: clang-tidy/bugprone/ExceptionEscapeCheck.cpp:176
+  Results.append(Rethrown.begin(), Rethrown.end());
+  Uncaught.erase(NewEnd, Uncaught.end());
+}

I'd put this as close to the remove_if as possible to allow readers keep less 
context to understand the code. In this case - as the first statement inside 
the `if`.


https://reviews.llvm.org/D33537



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


[PATCH] D40937: [clang-tidy] Infinite loop checker

2018-04-05 Thread Alexander Kornienko via Phabricator via cfe-commits
alexfh requested changes to this revision.
alexfh added inline comments.
This revision now requires changes to proceed.



Comment at: clang-tidy/bugprone/InfiniteLoopCheck.cpp:23-25
+static internal::Matcher loopEndingStmt() {
+  return stmt(anyOf(breakStmt(), returnStmt(), gotoStmt(), cxxThrowExpr()));
+}

This doesn't have to be a function. It can be a local variable or can be 
inlined into the callsite.



Comment at: clang-tidy/bugprone/InfiniteLoopCheck.cpp:32
+void InfiniteLoopCheck::registerMatchers(MatchFinder *Finder) {
+  const auto loopCondition = allOf(hasCondition(expr().bind("condition")),
+  anyOf(hasAncestor(lambdaExpr().bind("containing-lambda")),

http://llvm.org/docs/CodingStandards.html#name-types-functions-variables-and-enumerators-properly

> Variable names should be nouns (as they represent state). The name should be 
> camel case, and start with an upper case letter (e.g. Leader or Boats).



Comment at: clang-tidy/bugprone/InfiniteLoopCheck.cpp:105
+  return llvm::make_unique(
+  *(new ExprSequence(TheCFG.get(), &ASTCtx)));
+}

Why not just `llvm::make_unique(TheCFG.get(), &ASTCtx)`?

It also may be that you somehow lost a bunch of fixes, since this comment has 
already been addressed at some point: 
https://reviews.llvm.org/D40937?id=125870#inline-357357



Comment at: clang-tidy/bugprone/InfiniteLoopCheck.cpp:186
+  diag(LoopStmt->getLocStart(),
+   "%plural{1:The condition variable|:None of the condition variables}0 "
+   "(%1) %plural{1:is not|:are}0 updated in the loop body")

Clang diagnostics (and clang-tidy warnings) are not complete sentences and 
shouldn't start with a capital letter.


https://reviews.llvm.org/D40937



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


[PATCH] D45319: [Atomics] warn about misaligned atomic accesses using libcalls

2018-04-05 Thread Tim Northover via Phabricator via cfe-commits
t.p.northover created this revision.
t.p.northover added a reviewer: rsmith.
t.p.northover added a project: clang.
Herald added a subscriber: mcrosier.

If an atomic variable is misaligned Clang will emit accesses to it as a 
libcall. These calls are likely to be slow and involve locks; they are almost 
certainly not what the developer intended. So this patch adds a warning 
(promotable or ignorable) for tat situation.


Repository:
  rC Clang

https://reviews.llvm.org/D45319

Files:
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/CodeGen/CGAtomic.cpp
  clang/test/CodeGen/atomics-sema-alignment.c


Index: clang/test/CodeGen/atomics-sema-alignment.c
===
--- /dev/null
+++ clang/test/CodeGen/atomics-sema-alignment.c
@@ -0,0 +1,27 @@
+// RUN: %clang_cc1 -triple aarch64-linux-gnu %s -emit-llvm -o /dev/null -verify
+
+typedef struct {
+  int a, b;
+} IntPair;
+
+typedef struct {
+  long long a;
+} LongStruct;
+
+typedef int __attribute__((aligned(1))) unaligned_int;
+
+void func(IntPair *p) {
+  IntPair res;
+  __atomic_load(p, &res, 0); // expected-warning {{misaligned atomic operation 
may incur significant performance penalty}}
+  __atomic_store(p, &res, 0); // expected-warning {{misaligned atomic 
operation may incur significant performance penalty}}
+  __atomic_fetch_add((unaligned_int *)p, 1, 2); // expected-warning 
{{misaligned atomic operation may incur significant performance penalty}}
+  __atomic_fetch_sub((unaligned_int *)p, 1, 3); // expected-warning 
{{misaligned atomic operation may incur significant performance penalty}}
+}
+
+void func1(LongStruct *p) {
+  LongStruct res;
+  __atomic_load(p, &res, 0);
+  __atomic_store(p, &res, 0);
+  __atomic_fetch_add((int *)p, 1, 2);
+  __atomic_fetch_sub((int *)p, 1, 3);
+}
Index: clang/lib/CodeGen/CGAtomic.cpp
===
--- clang/lib/CodeGen/CGAtomic.cpp
+++ clang/lib/CodeGen/CGAtomic.cpp
@@ -18,6 +18,7 @@
 #include "TargetInfo.h"
 #include "clang/AST/ASTContext.h"
 #include "clang/CodeGen/CGFunctionInfo.h"
+#include "clang/Sema/SemaDiagnostic.h"
 #include "llvm/ADT/DenseMap.h"
 #include "llvm/IR/DataLayout.h"
 #include "llvm/IR/Intrinsics.h"
@@ -879,6 +880,8 @@
 
   // Use a library call.  See: http://gcc.gnu.org/wiki/Atomic/GCCMM/LIbrary .
   if (UseLibcall) {
+CGM.getDiags().Report(E->getLocStart(), diag::warn_atomic_op_misaligned);
+
 bool UseOptimizedLibcall = false;
 switch (E->getOp()) {
 case AtomicExpr::AO__c11_atomic_init:
Index: clang/include/clang/Basic/DiagnosticSemaKinds.td
===
--- clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -7087,6 +7087,9 @@
   InGroup>;
 def err_atomic_op_has_invalid_synch_scope : Error<
   "synchronization scope argument to atomic operation is invalid">;
+def warn_atomic_op_misaligned : Warning<
+  "misaligned atomic operation may incur significant performance penalty">,
+  InGroup>;
 
 def err_overflow_builtin_must_be_int : Error<
   "operand argument to overflow builtin must be an integer (%0 invalid)">;


Index: clang/test/CodeGen/atomics-sema-alignment.c
===
--- /dev/null
+++ clang/test/CodeGen/atomics-sema-alignment.c
@@ -0,0 +1,27 @@
+// RUN: %clang_cc1 -triple aarch64-linux-gnu %s -emit-llvm -o /dev/null -verify
+
+typedef struct {
+  int a, b;
+} IntPair;
+
+typedef struct {
+  long long a;
+} LongStruct;
+
+typedef int __attribute__((aligned(1))) unaligned_int;
+
+void func(IntPair *p) {
+  IntPair res;
+  __atomic_load(p, &res, 0); // expected-warning {{misaligned atomic operation may incur significant performance penalty}}
+  __atomic_store(p, &res, 0); // expected-warning {{misaligned atomic operation may incur significant performance penalty}}
+  __atomic_fetch_add((unaligned_int *)p, 1, 2); // expected-warning {{misaligned atomic operation may incur significant performance penalty}}
+  __atomic_fetch_sub((unaligned_int *)p, 1, 3); // expected-warning {{misaligned atomic operation may incur significant performance penalty}}
+}
+
+void func1(LongStruct *p) {
+  LongStruct res;
+  __atomic_load(p, &res, 0);
+  __atomic_store(p, &res, 0);
+  __atomic_fetch_add((int *)p, 1, 2);
+  __atomic_fetch_sub((int *)p, 1, 3);
+}
Index: clang/lib/CodeGen/CGAtomic.cpp
===
--- clang/lib/CodeGen/CGAtomic.cpp
+++ clang/lib/CodeGen/CGAtomic.cpp
@@ -18,6 +18,7 @@
 #include "TargetInfo.h"
 #include "clang/AST/ASTContext.h"
 #include "clang/CodeGen/CGFunctionInfo.h"
+#include "clang/Sema/SemaDiagnostic.h"
 #include "llvm/ADT/DenseMap.h"
 #include "llvm/IR/DataLayout.h"
 #include "llvm/IR/Intrinsics.h"
@@ -879,6 +880,8 @@
 
   // Use a library call.  See: http://gcc.gnu.org/wiki/Atomic/GCCMM/LIbrary .
   if (UseLibcall) {
+CGM.getD

[PATCH] D45096: Allow the creation of human-friendly ASTDumper to arbitrary output stream

2018-04-05 Thread Alexander Kornienko via Phabricator via cfe-commits
alexfh accepted this revision.
alexfh added a comment.
This revision is now accepted and ready to land.

Looks good to me. One optional comment.




Comment at: include/clang/Frontend/ASTConsumers.h:39-41
 std::unique_ptr CreateASTDumper(StringRef FilterString,
  bool DumpDecls, bool Deserialize,
  bool DumpLookups);

With just three users of the old API it might make sense to just add a 
parameter to it and update the callers instead of adding another override.


Repository:
  rC Clang

https://reviews.llvm.org/D45096



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


[PATCH] D45059: [clang-tidy] Add check to catch comparisons in TEMP_FAILURE_RETRY

2018-04-05 Thread Alexander Kornienko via Phabricator via cfe-commits
alexfh requested changes to this revision.
alexfh added a comment.
This revision now requires changes to proceed.

The TEMP_FAILURE_RETRY macro is specific to the GNU C library (and environments 
that attempt to mimic it). The generic bugprone- module is not the best place 
for this check. I suggest moving it to android- as other similar checks are 
already there (and I suspect that your interest in this check is also related 
to android?). Alternatively, if there are other checks specific to the GNU C 
library planned, we could add a new module for it.




Comment at: clang-tidy/bugprone/ComparisonInTempFailureRetryCheck.cpp:77
+  diag(BinOp.getOperatorLoc(),
+   "Top-level comparisons should be moved out of TEMP_FAILURE_RETRY");
+

Diagnostic messages are not full sentences and should not start with a capital 
letter.



Comment at: 
docs/clang-tidy/checks/bugprone-comparison-in-temp-failure-retry.rst:7
+Diagnoses comparisons that appear to be incorrectly placed in the argument to
+the ``TEMP_FAILURE_RETRY`` macro. Having such a use is incorrect in the vast
+majority of cases, and will often silently defeat the purpose of the

The documentation should provide some context w.r.t what the TEMP_FAILURE_RETRY 
macro is and where it comes from (maybe also link to its documentation).


https://reviews.llvm.org/D45059



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


[PATCH] D45202: [X86] Replacing X86-specific floor and ceil vector intrinsics with generic LLVM intrinsics

2018-04-05 Thread Mikhail Dvoretckii via Phabricator via cfe-commits
mike.dvoretsky added inline comments.



Comment at: clang/lib/CodeGen/CGBuiltin.cpp:8307
+Dst = Ops[0];
+Mask = llvm::ConstantInt::get(CGF.Builder.getInt32Ty(), 1);
+  } else {

craig.topper wrote:
> I'm not sure we should even try to emit a mask for the legacy scalar 
> intrinsics. Does this get removed well by the middle or backend?
The masking is done to represent all operations handled here in a uniform way. 
D45203 removes it in the backend.


https://reviews.llvm.org/D45202



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


r329289 - [ObjC] Make C++ triviality type traits available to non-trivial C

2018-04-05 Thread Akira Hatanaka via cfe-commits
Author: ahatanak
Date: Thu Apr  5 07:39:57 2018
New Revision: 329289

URL: http://llvm.org/viewvc/llvm-project?rev=329289&view=rev
Log:
[ObjC] Make C++ triviality type traits available to non-trivial C
structs.

r326307 and r327870 made changes that allowed using non-trivial C
structs with fields qualified with __strong or __weak. This commit makes
the following C++ triviality type traits available to non-trivial C
structs:

__has_trivial_assign
__has_trivial_move_assign
__has_trivial_copy
__has_trivial_move_constructor
__has_trivial_constructor
__has_trivial_destructor

This reapplies r328680. This commit fixes a bug where the copy/move
__has_trivial_* traits would return false when a volatile type was being
passed. Thanks to Richard Smith for pointing out the mistake.

rdar://problem/33599681

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

Added:
cfe/trunk/test/SemaObjC/non-trivial-struct-traits.m
Modified:
cfe/trunk/include/clang/Basic/TokenKinds.def
cfe/trunk/lib/Sema/SemaExprCXX.cpp

Modified: cfe/trunk/include/clang/Basic/TokenKinds.def
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/TokenKinds.def?rev=329289&r1=329288&r2=329289&view=diff
==
--- cfe/trunk/include/clang/Basic/TokenKinds.def (original)
+++ cfe/trunk/include/clang/Basic/TokenKinds.def Thu Apr  5 07:39:57 2018
@@ -433,12 +433,12 @@ TYPE_TRAIT_1(__has_nothrow_assign, HasNo
 TYPE_TRAIT_1(__has_nothrow_move_assign, HasNothrowMoveAssign, KEYCXX)
 TYPE_TRAIT_1(__has_nothrow_copy, HasNothrowCopy, KEYCXX)
 TYPE_TRAIT_1(__has_nothrow_constructor, HasNothrowConstructor, KEYCXX)
-TYPE_TRAIT_1(__has_trivial_assign, HasTrivialAssign, KEYCXX)
-TYPE_TRAIT_1(__has_trivial_move_assign, HasTrivialMoveAssign, KEYCXX)
-TYPE_TRAIT_1(__has_trivial_copy, HasTrivialCopy, KEYCXX)
-TYPE_TRAIT_1(__has_trivial_constructor, HasTrivialDefaultConstructor, KEYCXX)
-TYPE_TRAIT_1(__has_trivial_move_constructor, HasTrivialMoveConstructor, KEYCXX)
-TYPE_TRAIT_1(__has_trivial_destructor, HasTrivialDestructor, KEYCXX)
+TYPE_TRAIT_1(__has_trivial_assign, HasTrivialAssign, KEYALL)
+TYPE_TRAIT_1(__has_trivial_move_assign, HasTrivialMoveAssign, KEYALL)
+TYPE_TRAIT_1(__has_trivial_copy, HasTrivialCopy, KEYALL)
+TYPE_TRAIT_1(__has_trivial_constructor, HasTrivialDefaultConstructor, KEYALL)
+TYPE_TRAIT_1(__has_trivial_move_constructor, HasTrivialMoveConstructor, KEYALL)
+TYPE_TRAIT_1(__has_trivial_destructor, HasTrivialDestructor, KEYALL)
 TYPE_TRAIT_1(__has_virtual_destructor, HasVirtualDestructor, KEYCXX)
 TYPE_TRAIT_1(__is_abstract, IsAbstract, KEYCXX)
 TYPE_TRAIT_1(__is_aggregate, IsAggregate, KEYCXX)

Modified: cfe/trunk/lib/Sema/SemaExprCXX.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExprCXX.cpp?rev=329289&r1=329288&r2=329289&view=diff
==
--- cfe/trunk/lib/Sema/SemaExprCXX.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExprCXX.cpp Thu Apr  5 07:39:57 2018
@@ -4521,6 +4521,8 @@ static bool EvaluateUnaryTypeTrait(Sema
 // does not correctly compute triviality in the presence of multiple 
special
 // members of the same kind. Revisit this once the g++ bug is fixed.
   case UTT_HasTrivialDefaultConstructor:
+if (T.isNonTrivialToPrimitiveDefaultInitialize())
+  return false;
 // http://gcc.gnu.org/onlinedocs/gcc/Type-Traits.html:
 //   If __is_pod (type) is true then the trait is true, else if type is
 //   a cv class or union type (or array thereof) with a trivial default
@@ -4531,7 +4533,11 @@ static bool EvaluateUnaryTypeTrait(Sema
   return RD->hasTrivialDefaultConstructor() &&
  !RD->hasNonTrivialDefaultConstructor();
 return false;
-  case UTT_HasTrivialMoveConstructor:
+  case UTT_HasTrivialMoveConstructor: {
+QualType::PrimitiveCopyKind PCK =
+T.isNonTrivialToPrimitiveDestructiveMove();
+if (PCK != QualType::PCK_Trivial && PCK != QualType::PCK_VolatileTrivial)
+  return false;
 //  This trait is implemented by MSVC 2012 and needed to parse the
 //  standard library headers. Specifically this is used as the logic
 //  behind std::is_trivially_move_constructible (20.9.4.3).
@@ -4540,7 +4546,11 @@ static bool EvaluateUnaryTypeTrait(Sema
 if (CXXRecordDecl *RD = C.getBaseElementType(T)->getAsCXXRecordDecl())
   return RD->hasTrivialMoveConstructor() && 
!RD->hasNonTrivialMoveConstructor();
 return false;
-  case UTT_HasTrivialCopy:
+  }
+  case UTT_HasTrivialCopy: {
+QualType::PrimitiveCopyKind PCK = T.isNonTrivialToPrimitiveCopy();
+if (PCK != QualType::PCK_Trivial && PCK != QualType::PCK_VolatileTrivial)
+  return false;
 // http://gcc.gnu.org/onlinedocs/gcc/Type-Traits.html:
 //   If __is_pod (type) is true or type is a reference type then
 //   the trait is true, else if type is a cv class or union type
@@ -4552,7 +4562,12 @@ static bool Evaluate

[PATCH] D43764: [clang-apply-replacements] Convert tooling::Replacements to tooling::AtomicChange for conflict resolving of changes, code cleanup, and code formatting.

2018-04-05 Thread Malcolm Parsons via Phabricator via cfe-commits
malcolm.parsons added a comment.

In https://reviews.llvm.org/D43764#1058120, @jdemeule wrote:

> Can I help in some way to close this PR?


I applied the patch and ran the tests.

There was one unexpected failure:

  [100%] Running the Clang extra tools' regression tests
  FAIL: Clang Tools :: clang-apply-replacements/conflict.cpp (10 of 896)
   TEST 'Clang Tools :: 
clang-apply-replacements/conflict.cpp' FAILED 
  Script:
  --
  mkdir -p 
/mparsons/llvm/llvm-build/tools/clang/tools/extra/test/clang-apply-replacements/Output/Inputs/conflict
  sed 
"s#\$(path)#/mparsons/llvm/llvm/tools/clang/tools/extra/test/clang-apply-replacements/Inputs/conflict#"
 
/mparsons/llvm/llvm/tools/clang/tools/extra/test/clang-apply-replacements/Inputs/conflict/file1.yaml
 > 
/mparsons/llvm/llvm-build/tools/clang/tools/extra/test/clang-apply-replacements/Output/Inputs/conflict/file1.yaml
  sed 
"s#\$(path)#/mparsons/llvm/llvm/tools/clang/tools/extra/test/clang-apply-replacements/Inputs/conflict#"
 
/mparsons/llvm/llvm/tools/clang/tools/extra/test/clang-apply-replacements/Inputs/conflict/file2.yaml
 > 
/mparsons/llvm/llvm-build/tools/clang/tools/extra/test/clang-apply-replacements/Output/Inputs/conflict/file2.yaml
  sed 
"s#\$(path)#/mparsons/llvm/llvm/tools/clang/tools/extra/test/clang-apply-replacements/Inputs/conflict#"
 
/mparsons/llvm/llvm/tools/clang/tools/extra/test/clang-apply-replacements/Inputs/conflict/file3.yaml
 > 
/mparsons/llvm/llvm-build/tools/clang/tools/extra/test/clang-apply-replacements/Output/Inputs/conflict/file3.yaml
  sed 
"s#\$(path)#/mparsons/llvm/llvm/tools/clang/tools/extra/test/clang-apply-replacements/Inputs/conflict#"
 
/mparsons/llvm/llvm/tools/clang/tools/extra/test/clang-apply-replacements/Inputs/conflict/expected.txt
 > 
/mparsons/llvm/llvm-build/tools/clang/tools/extra/test/clang-apply-replacements/Output/Inputs/conflict/expected.txt
  not clang-apply-replacements 
/mparsons/llvm/llvm-build/tools/clang/tools/extra/test/clang-apply-replacements/Output/Inputs/conflict
 > 
/mparsons/llvm/llvm-build/tools/clang/tools/extra/test/clang-apply-replacements/Output/Inputs/conflict/output.txt
 2>&1
  diff -b 
/mparsons/llvm/llvm-build/tools/clang/tools/extra/test/clang-apply-replacements/Output/Inputs/conflict/output.txt
 
/mparsons/llvm/llvm-build/tools/clang/tools/extra/test/clang-apply-replacements/Output/Inputs/conflict/expected.txt
  ls -1 
/mparsons/llvm/llvm-build/tools/clang/tools/extra/test/clang-apply-replacements/Output/Inputs/conflict
 | FileCheck 
/mparsons/llvm/llvm/tools/clang/tools/extra/test/clang-apply-replacements/conflict.cpp
 --check-prefix=YAML
  not clang-apply-replacements 
/mparsons/llvm/llvm-build/tools/clang/tools/extra/test/clang-apply-replacements/Output/Inputs/conflict
 -remove-change-desc-files > 
/mparsons/llvm/llvm-build/tools/clang/tools/extra/test/clang-apply-replacements/Output/Inputs/conflict/output.txt
 2>&1
  ls -1 
/mparsons/llvm/llvm-build/tools/clang/tools/extra/test/clang-apply-replacements/Output/Inputs/conflict
 | FileCheck 
/mparsons/llvm/llvm/tools/clang/tools/extra/test/clang-apply-replacements/conflict.cpp
 --check-prefix=NO_YAML
  --
  Exit Code: 1
  
  Command Output (stdout):
  --
  2,4d1
  < New replacement: 
/mparsons/llvm/llvm/tools/clang/tools/extra/test/clang-apply-replacements/Inputs/conflict/common.h:
 169:+0:"(int*)"
  < Existing replacement: 
/mparsons/llvm/llvm/tools/clang/tools/extra/test/clang-apply-replacements/Inputs/conflict/common.h:
 160:+12:""
  < The new replacement overlaps with an existing replacement.
  11a9,11
  > Existing replacement: 
/mparsons/llvm/llvm/tools/clang/tools/extra/test/clang-apply-replacements/Inputs/conflict/common.h:
 160:+12:""
  > The new replacement overlaps with an existing replacement.
  > New replacement: 
/mparsons/llvm/llvm/tools/clang/tools/extra/test/clang-apply-replacements/Inputs/conflict/common.h:
 169:+0:"(int*)"
  
  --
  
  
  Testing Time: 21.09s
  
  Failing Tests (1):
  Clang Tools :: clang-apply-replacements/conflict.cpp
  
Expected Passes: 893
Unsupported Tests  : 2
Unexpected Failures: 1


https://reviews.llvm.org/D43764



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


[libclc] r329290 - amdgcn: Update datalayout after LLVM r328656

2018-04-05 Thread Jan Vesely via cfe-commits
Author: jvesely
Date: Thu Apr  5 07:47:44 2018
New Revision: 329290

URL: http://llvm.org/viewvc/llvm-project?rev=329290&view=rev
Log:
amdgcn: Update datalayout after LLVM r328656

Signed-off-by: Jan Vesely 
Reviewed-by: Aaron Watry 

Modified:
libclc/trunk/amdgcn/lib/cl_khr_int64_extended_atomics/minmax_helpers.ll
libclc/trunk/amdgcn/lib/workitem/get_global_size.ll
libclc/trunk/amdgcn/lib/workitem/get_local_size.ll
libclc/trunk/amdgcn/lib/workitem/get_num_groups.ll

Modified: 
libclc/trunk/amdgcn/lib/cl_khr_int64_extended_atomics/minmax_helpers.ll
URL: 
http://llvm.org/viewvc/llvm-project/libclc/trunk/amdgcn/lib/cl_khr_int64_extended_atomics/minmax_helpers.ll?rev=329290&r1=329289&r2=329290&view=diff
==
--- libclc/trunk/amdgcn/lib/cl_khr_int64_extended_atomics/minmax_helpers.ll 
(original)
+++ libclc/trunk/amdgcn/lib/cl_khr_int64_extended_atomics/minmax_helpers.ll Thu 
Apr  5 07:47:44 2018
@@ -1,4 +1,4 @@
-target datalayout = 
"e-p:64:64-p1:64:64-p2:32:32-p3:32:32-p4:64:64-p5:32:32-p6:32:32-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-v512:512-v1024:1024-v2048:2048-n32:64-A5"
+target datalayout = 
"e-p:64:64-p1:64:64-p2:32:32-p3:32:32-p4:64:64-p5:32:32-p6:32:32-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-v512:512-v1024:1024-v2048:2048-n32:64-S32-A5"
 
 define i64 @__clc__sync_fetch_and_min_global_8(i64 addrspace(1)* nocapture 
%ptr, i64 %value) nounwind alwaysinline {
 entry:

Modified: libclc/trunk/amdgcn/lib/workitem/get_global_size.ll
URL: 
http://llvm.org/viewvc/llvm-project/libclc/trunk/amdgcn/lib/workitem/get_global_size.ll?rev=329290&r1=329289&r2=329290&view=diff
==
--- libclc/trunk/amdgcn/lib/workitem/get_global_size.ll (original)
+++ libclc/trunk/amdgcn/lib/workitem/get_global_size.ll Thu Apr  5 07:47:44 2018
@@ -2,7 +2,7 @@ declare i32 @llvm.r600.read.global.size.
 declare i32 @llvm.r600.read.global.size.y() nounwind readnone
 declare i32 @llvm.r600.read.global.size.z() nounwind readnone
 
-target datalayout = 
"e-p:64:64-p1:64:64-p2:32:32-p3:32:32-p4:64:64-p5:32:32-p6:32:32-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-v512:512-v1024:1024-v2048:2048-n32:64-A5"
+target datalayout = 
"e-p:64:64-p1:64:64-p2:32:32-p3:32:32-p4:64:64-p5:32:32-p6:32:32-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-v512:512-v1024:1024-v2048:2048-n32:64-S32-A5"
 
 define i64 @get_global_size(i32 %dim) nounwind readnone alwaysinline {
   switch i32 %dim, label %default [i32 0, label %x_dim i32 1, label %y_dim i32 
2, label %z_dim]

Modified: libclc/trunk/amdgcn/lib/workitem/get_local_size.ll
URL: 
http://llvm.org/viewvc/llvm-project/libclc/trunk/amdgcn/lib/workitem/get_local_size.ll?rev=329290&r1=329289&r2=329290&view=diff
==
--- libclc/trunk/amdgcn/lib/workitem/get_local_size.ll (original)
+++ libclc/trunk/amdgcn/lib/workitem/get_local_size.ll Thu Apr  5 07:47:44 2018
@@ -2,7 +2,7 @@ declare i32 @llvm.r600.read.local.size.x
 declare i32 @llvm.r600.read.local.size.y() nounwind readnone
 declare i32 @llvm.r600.read.local.size.z() nounwind readnone
 
-target datalayout = 
"e-p:64:64-p1:64:64-p2:32:32-p3:32:32-p4:64:64-p5:32:32-p6:32:32-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-v512:512-v1024:1024-v2048:2048-n32:64-A5"
+target datalayout = 
"e-p:64:64-p1:64:64-p2:32:32-p3:32:32-p4:64:64-p5:32:32-p6:32:32-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-v512:512-v1024:1024-v2048:2048-n32:64-S32-A5"
 
 define i64 @get_local_size(i32 %dim) nounwind readnone alwaysinline {
   switch i32 %dim, label %default [i32 0, label %x_dim i32 1, label %y_dim i32 
2, label %z_dim]

Modified: libclc/trunk/amdgcn/lib/workitem/get_num_groups.ll
URL: 
http://llvm.org/viewvc/llvm-project/libclc/trunk/amdgcn/lib/workitem/get_num_groups.ll?rev=329290&r1=329289&r2=329290&view=diff
==
--- libclc/trunk/amdgcn/lib/workitem/get_num_groups.ll (original)
+++ libclc/trunk/amdgcn/lib/workitem/get_num_groups.ll Thu Apr  5 07:47:44 2018
@@ -2,7 +2,7 @@ declare i32 @llvm.r600.read.ngroups.x()
 declare i32 @llvm.r600.read.ngroups.y() nounwind readnone
 declare i32 @llvm.r600.read.ngroups.z() nounwind readnone
 
-target datalayout = 
"e-p:64:64-p1:64:64-p2:32:32-p3:32:32-p4:64:64-p5:32:32-p6:32:32-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-v512:512-v1024:1024-v2048:2048-n32:64-A5"
+target datalayout = 
"e-p:64:64-p1:64:64-p2:32:32-p3:32:32-p4:64:64-p5:32:32-p6:32:32-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-v512:512-v1024:1024-v2048:2048-n32:64-S32-A5"
 
 define i64 @get_num_groups(i32 %dim) nounwind readnone alwaysinline {
   switch i32 %dim, label %default [i32 0, label %x_dim i32 1, label %y_dim i32 
2, label %z_dim

[libclc] r329291 - r600: Update datalayout after LLVM r328656

2018-04-05 Thread Jan Vesely via cfe-commits
Author: jvesely
Date: Thu Apr  5 07:47:57 2018
New Revision: 329291

URL: http://llvm.org/viewvc/llvm-project?rev=329291&view=rev
Log:
r600: Update datalayout after LLVM r328656

Signed-off-by: Jan Vesely 
Reviewed-by: Aaron Watry 

Modified:
libclc/trunk/r600/lib/synchronization/barrier_impl.ll
libclc/trunk/r600/lib/workitem/get_global_size.ll
libclc/trunk/r600/lib/workitem/get_local_size.ll
libclc/trunk/r600/lib/workitem/get_num_groups.ll

Modified: libclc/trunk/r600/lib/synchronization/barrier_impl.ll
URL: 
http://llvm.org/viewvc/llvm-project/libclc/trunk/r600/lib/synchronization/barrier_impl.ll?rev=329291&r1=329290&r2=329291&view=diff
==
--- libclc/trunk/r600/lib/synchronization/barrier_impl.ll (original)
+++ libclc/trunk/r600/lib/synchronization/barrier_impl.ll Thu Apr  5 07:47:57 
2018
@@ -1,6 +1,6 @@
 declare void @llvm.r600.group.barrier() #0
 
-target datalayout = 
"e-p:32:32-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-v512:512-v1024:1024-v2048:2048-n32:64-A5"
+target datalayout = 
"e-p:32:32-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-v512:512-v1024:1024-v2048:2048-n32:64-S32-A5"
 
 define void @barrier(i32 %flags) #1 {
 entry:

Modified: libclc/trunk/r600/lib/workitem/get_global_size.ll
URL: 
http://llvm.org/viewvc/llvm-project/libclc/trunk/r600/lib/workitem/get_global_size.ll?rev=329291&r1=329290&r2=329291&view=diff
==
--- libclc/trunk/r600/lib/workitem/get_global_size.ll (original)
+++ libclc/trunk/r600/lib/workitem/get_global_size.ll Thu Apr  5 07:47:57 2018
@@ -2,7 +2,7 @@ declare i32 @llvm.r600.read.global.size.
 declare i32 @llvm.r600.read.global.size.y() nounwind readnone
 declare i32 @llvm.r600.read.global.size.z() nounwind readnone
 
-target datalayout = 
"e-p:32:32-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-v512:512-v1024:1024-v2048:2048-n32:64-A5"
+target datalayout = 
"e-p:32:32-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-v512:512-v1024:1024-v2048:2048-n32:64-S32-A5"
 
 define i32 @get_global_size(i32 %dim) nounwind readnone alwaysinline {
   switch i32 %dim, label %default [i32 0, label %x_dim i32 1, label %y_dim i32 
2, label %z_dim]

Modified: libclc/trunk/r600/lib/workitem/get_local_size.ll
URL: 
http://llvm.org/viewvc/llvm-project/libclc/trunk/r600/lib/workitem/get_local_size.ll?rev=329291&r1=329290&r2=329291&view=diff
==
--- libclc/trunk/r600/lib/workitem/get_local_size.ll (original)
+++ libclc/trunk/r600/lib/workitem/get_local_size.ll Thu Apr  5 07:47:57 2018
@@ -2,7 +2,7 @@ declare i32 @llvm.r600.read.local.size.x
 declare i32 @llvm.r600.read.local.size.y() nounwind readnone
 declare i32 @llvm.r600.read.local.size.z() nounwind readnone
 
-target datalayout = 
"e-p:32:32-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-v512:512-v1024:1024-v2048:2048-n32:64-A5"
+target datalayout = 
"e-p:32:32-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-v512:512-v1024:1024-v2048:2048-n32:64-S32-A5"
 
 define i32 @get_local_size(i32 %dim) nounwind readnone alwaysinline {
   switch i32 %dim, label %default [i32 0, label %x_dim i32 1, label %y_dim i32 
2, label %z_dim]

Modified: libclc/trunk/r600/lib/workitem/get_num_groups.ll
URL: 
http://llvm.org/viewvc/llvm-project/libclc/trunk/r600/lib/workitem/get_num_groups.ll?rev=329291&r1=329290&r2=329291&view=diff
==
--- libclc/trunk/r600/lib/workitem/get_num_groups.ll (original)
+++ libclc/trunk/r600/lib/workitem/get_num_groups.ll Thu Apr  5 07:47:57 2018
@@ -2,7 +2,7 @@ declare i32 @llvm.r600.read.ngroups.x()
 declare i32 @llvm.r600.read.ngroups.y() nounwind readnone
 declare i32 @llvm.r600.read.ngroups.z() nounwind readnone
 
-target datalayout = 
"e-p:32:32-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-v512:512-v1024:1024-v2048:2048-n32:64-A5"
+target datalayout = 
"e-p:32:32-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-v512:512-v1024:1024-v2048:2048-n32:64-S32-A5"
 
 define i32 @get_num_groups(i32 %dim) nounwind readnone alwaysinline {
   switch i32 %dim, label %default [i32 0, label %x_dim i32 1, label %y_dim i32 
2, label %z_dim]


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


Re: r328680 - [ObjC] Make C++ triviality type traits available to non-trivial C

2018-04-05 Thread Akira Hatanaka via cfe-commits


> On Apr 4, 2018, at 5:38 PM, Richard Smith  wrote:
> 
> On 4 April 2018 at 16:57, Akira Hatanaka via cfe-commits 
> mailto:cfe-commits@lists.llvm.org>> wrote:
> 
>> On Apr 4, 2018, at 4:47 PM, Richard Smith > > wrote:
>> 
>> On 4 April 2018 at 16:24, Akira Hatanaka via cfe-commits 
>> mailto:cfe-commits@lists.llvm.org>> wrote:
>> 
>>> On Apr 4, 2018, at 3:38 PM, Richard Smith >> > wrote:
>>> 
>>> Hi Akira,
>>> 
>>> This change has broken the C++ versions of these type traits for classes 
>>> with volatile members. Such classes are required to claim to be trivial per 
>>> C++ DR 2094 
>>> (http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#2094 
>>> ) but 
>>> return false from isNonTrivialToPrimitiveCopy().
>>> 
>> 
>> Oh that’s right. The function returns false when 
>> isNonTrivialToPrimitiveCopy() returns PCK_VolatileTrivial. That is wrong.
>> 
>> Do you have a fix that's going to land soon? This has caused a regression 
>> for us, so I'd like to revert if it's not going to be fixed imminently.
> 
> Yes, I plan to fix this soon, but feel free to revert it if you need to.
> 
>  Reverted in r329247 for now.

Sorry, I wasn’t able to fix it soon enough, I reapplied the patch with a fix in 
r329289. Let me know if it’s still causing a regression.

>>> Also, exposing these __has_* traits more widely seems like a backwards step 
>>> to me: these traits are deprecated, near-useless, and we're trying to 
>>> remove them. No code should be using them under any circumstances; the 
>>> __is_* traits should be used instead.
>>> 
>> 
>> The __is_* traits (is_trivially_copy_constructible, etc.) are templates 
>> defined in libcxx, so it seems that we can’t use them when compiling in C 
>> mode. Is it OK to add their definitions to TokenKinds.def as non-C++ 
>> keywords?
>> 
>>> On 27 March 2018 at 17:12, Akira Hatanaka via cfe-commits 
>>> mailto:cfe-commits@lists.llvm.org>> wrote:
>>> Author: ahatanak
>>> Date: Tue Mar 27 17:12:08 2018
>>> New Revision: 328680
>>> 
>>> URL: http://llvm.org/viewvc/llvm-project?rev=328680&view=rev 
>>> 
>>> Log:
>>> [ObjC] Make C++ triviality type traits available to non-trivial C
>>> structs.
>>> 
>>> r326307 and r327870 made changes that allowed using non-trivial C
>>> structs with fields qualified with __strong or __weak. This commit makes
>>> the following C++ triviality type traits available to non-trivial C
>>> structs:
>>> 
>>> __has_trivial_assign
>>> __has_trivial_move_assign
>>> __has_trivial_copy
>>> __has_trivial_move_constructor
>>> __has_trivial_constructor
>>> __has_trivial_destructor
>>> 
>>> rdar://problem/33599681 <>
>>> 
>>> Differential Revision: https://reviews.llvm.org/D44913 
>>> 
>>> 
>>> Added:
>>> cfe/trunk/test/SemaObjC/non-trivial-struct-traits.m
>>> Modified:
>>> cfe/trunk/include/clang/Basic/TokenKinds.def
>>> cfe/trunk/lib/Sema/SemaExprCXX.cpp
>>> 
>>> Modified: cfe/trunk/include/clang/Basic/TokenKinds.def
>>> URL: 
>>> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/TokenKinds.def?rev=328680&r1=328679&r2=328680&view=diff
>>>  
>>> 
>>> ==
>>> --- cfe/trunk/include/clang/Basic/TokenKinds.def (original)
>>> +++ cfe/trunk/include/clang/Basic/TokenKinds.def Tue Mar 27 17:12:08 2018
>>> @@ -433,12 +433,12 @@ TYPE_TRAIT_1(__has_nothrow_assign, HasNo
>>>  TYPE_TRAIT_1(__has_nothrow_move_assign, HasNothrowMoveAssign, KEYCXX)
>>>  TYPE_TRAIT_1(__has_nothrow_copy, HasNothrowCopy, KEYCXX)
>>>  TYPE_TRAIT_1(__has_nothrow_constructor, HasNothrowConstructor, KEYCXX)
>>> -TYPE_TRAIT_1(__has_trivial_assign, HasTrivialAssign, KEYCXX)
>>> -TYPE_TRAIT_1(__has_trivial_move_assign, HasTrivialMoveAssign, KEYCXX)
>>> -TYPE_TRAIT_1(__has_trivial_copy, HasTrivialCopy, KEYCXX)
>>> -TYPE_TRAIT_1(__has_trivial_constructor, HasTrivialDefaultConstructor, 
>>> KEYCXX)
>>> -TYPE_TRAIT_1(__has_trivial_move_constructor, HasTrivialMoveConstructor, 
>>> KEYCXX)
>>> -TYPE_TRAIT_1(__has_trivial_destructor, HasTrivialDestructor, KEYCXX)
>>> +TYPE_TRAIT_1(__has_trivial_assign, HasTrivialAssign, KEYALL)
>>> +TYPE_TRAIT_1(__has_trivial_move_assign, HasTrivialMoveAssign, KEYALL)
>>> +TYPE_TRAIT_1(__has_trivial_copy, HasTrivialCopy, KEYALL)
>>> +TYPE_TRAIT_1(__has_trivial_constructor, HasTrivialDefaultConstructor, 
>>> KEYALL)
>>> +TYPE_TRAIT_1(__has_trivial_move_constructor, HasTrivialMoveConstructor, 
>>> KEYALL)
>>> +TYPE_TRAIT_1(__has_trivial_destructor, HasTrivialDestructor, KEYALL)
>>>  TYPE_TRAIT_1(__has_virtual_destructor, HasVirtualDestructor, KEYCXX)
>>>  TYPE_TRAIT_1(__is_abstract, IsAbstract, KEYCXX)
>>>  TYPE_TRAIT_1(__is_aggregate, I

[clang-tools-extra] r329292 - [clang-tidy] Remove google-runtime-member-string-references

2018-04-05 Thread Benjamin Kramer via cfe-commits
Author: d0k
Date: Thu Apr  5 07:51:01 2018
New Revision: 329292

URL: http://llvm.org/viewvc/llvm-project?rev=329292&view=rev
Log:
[clang-tidy] Remove google-runtime-member-string-references

This is triggering on a pattern that's both too broad (const
std::string& members can be used safely) and too narrow (std::string is
not the only class with this problem). It has a very low true positive
rate, just remove it until we find a better solution for dangling string
references.

Removed:
clang-tools-extra/trunk/clang-tidy/google/StringReferenceMemberCheck.cpp
clang-tools-extra/trunk/clang-tidy/google/StringReferenceMemberCheck.h

clang-tools-extra/trunk/docs/clang-tidy/checks/google-runtime-member-string-references.rst

clang-tools-extra/trunk/test/clang-tidy/google-runtime-member-string-references.cpp
Modified:

clang-tools-extra/trunk/clang-tidy-vs/ClangTidy/Resources/ClangTidyChecks.yaml
clang-tools-extra/trunk/clang-tidy/google/CMakeLists.txt
clang-tools-extra/trunk/clang-tidy/google/GoogleTidyModule.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-vs/ClangTidy/Resources/ClangTidyChecks.yaml
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy-vs/ClangTidy/Resources/ClangTidyChecks.yaml?rev=329292&r1=329291&r2=329292&view=diff
==
--- 
clang-tools-extra/trunk/clang-tidy-vs/ClangTidy/Resources/ClangTidyChecks.yaml 
(original)
+++ 
clang-tools-extra/trunk/clang-tidy-vs/ClangTidy/Resources/ClangTidyChecks.yaml 
Thu Apr  5 07:51:01 2018
@@ -115,10 +115,6 @@ Checks:
 Description: 
 Name:google-runtime-int
   - Category:Google Style Guide
-Label:   Find const string references
-Description: 
-Name:google-runtime-member-string-references
-  - Category:Google Style Guide
 Label:   Find zero-length memsets
 Description: 
 Name:google-runtime-memset

Modified: clang-tools-extra/trunk/clang-tidy/google/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/google/CMakeLists.txt?rev=329292&r1=329291&r2=329292&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/google/CMakeLists.txt (original)
+++ clang-tools-extra/trunk/clang-tidy/google/CMakeLists.txt Thu Apr  5 
07:51:01 2018
@@ -12,7 +12,6 @@ add_clang_library(clangTidyGoogleModule
   IntegerTypesCheck.cpp
   NonConstReferences.cpp
   OverloadedUnaryAndCheck.cpp
-  StringReferenceMemberCheck.cpp
   TodoCommentCheck.cpp
   UnnamedNamespaceInHeaderCheck.cpp
   UsingNamespaceDirectiveCheck.cpp

Modified: clang-tools-extra/trunk/clang-tidy/google/GoogleTidyModule.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/google/GoogleTidyModule.cpp?rev=329292&r1=329291&r2=329292&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/google/GoogleTidyModule.cpp (original)
+++ clang-tools-extra/trunk/clang-tidy/google/GoogleTidyModule.cpp Thu Apr  5 
07:51:01 2018
@@ -24,7 +24,6 @@
 #include "IntegerTypesCheck.h"
 #include "NonConstReferences.h"
 #include "OverloadedUnaryAndCheck.h"
-#include "StringReferenceMemberCheck.h"
 #include "TodoCommentCheck.h"
 #include "UnnamedNamespaceInHeaderCheck.h"
 #include "UsingNamespaceDirectiveCheck.h"
@@ -60,8 +59,6 @@ class GoogleModule : public ClangTidyMod
 "google-runtime-operator");
 CheckFactories.registerCheck(
 "google-runtime-references");
-CheckFactories.registerCheck(
-"google-runtime-member-string-references");
 CheckFactories.registerCheck(
 "google-readability-casting");
 CheckFactories.registerCheck(

Removed: 
clang-tools-extra/trunk/clang-tidy/google/StringReferenceMemberCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/google/StringReferenceMemberCheck.cpp?rev=329291&view=auto
==
--- clang-tools-extra/trunk/clang-tidy/google/StringReferenceMemberCheck.cpp 
(original)
+++ clang-tools-extra/trunk/clang-tidy/google/StringReferenceMemberCheck.cpp 
(removed)
@@ -1,51 +0,0 @@
-//===--- StringReferenceMemberCheck.cpp - clang-tidy *- C++ 
-*-===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===--===//
-
-#include "StringReferenceMemberCheck.h"
-#include "clang/AST/ASTContext.h"
-#include "clang/ASTMatchers/ASTMatchFinder.h"
-#include "clang/ASTMatchers/ASTMatchers.h"
-
-using namespace clang::ast_matchers;
-
-namespace clang {
-namespa

[PATCH] D45240: [ARM] Compute a target feature which corresponds to the ARM version.

2018-04-05 Thread Florian Hahn via Phabricator via cfe-commits
fhahn added inline comments.



Comment at: lib/Basic/Targets/ARM.cpp:345
   // get default FPU features
+  llvm::ARM::ArchKind Arch = llvm::ARM::parseArch(getTriple().getArchName());
   unsigned FPUKind = llvm::ARM::getDefaultFPU(CPU, Arch);

Is there a reason we re-compute the Arch from the triple here, but use the 
member variable ArchKind above? Shouldn't they both be the same ?


Repository:
  rC Clang

https://reviews.llvm.org/D45240



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


[PATCH] D45185: [clang-format] Support lightweight Objective-C generics

2018-04-05 Thread Daniel Jasper via Phabricator via cfe-commits
djasper accepted this revision.
djasper added a comment.
This revision is now accepted and ready to land.

Looks good, thank you!


Repository:
  rC Clang

https://reviews.llvm.org/D45185



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


[PATCH] D45004: [clang-format] New style option IndentWrappedObjCMethodNames

2018-04-05 Thread Ben Hamilton via Phabricator via cfe-commits
benhamilton added a comment.

> a user sets the existing IndentWrappedFunctionNames to true for ObjC and to 
> false for C++.
>  Now IMO, that should mean that ObjC function names are indented and C++ 
> functions are not, even if the language of the *file* is ObjC. 
>  Getting this right will require some refactoring of how a style is passed 
> around and used, but I think it'd be the right thing to do.

This is an interesting proposal, but adding infrastructure to pass around and 
manage per-language `FormatStyle` objects to formatter logic seems like a large 
change to me, and a lot of work to avoid adding a new configuration option.

Without changing the architecture to pass around per-language `FormatStyle`s, 
we could also unconditionally indent wrapped Objective-C methods in all styles 
(ignoring `IndentWrappedFunctionNames`) and make `IndentWrappedFunctionNames` 
only apply to C++ functions and methods.

I just did a survey of open-source Objective-C code in use at Google, and it's 
over 5:1 in favor of indenting wrapped Objective-C methods.

What do you think of that option?


Repository:
  rC Clang

https://reviews.llvm.org/D45004



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


r329297 - [clang-format] Ensure ObjC selectors with 0 args are annotated correctly

2018-04-05 Thread Ben Hamilton via cfe-commits
Author: benhamilton
Date: Thu Apr  5 08:26:23 2018
New Revision: 329297

URL: http://llvm.org/viewvc/llvm-project?rev=329297&view=rev
Log:
[clang-format] Ensure ObjC selectors with 0 args are annotated correctly

Summary:
Previously, clang-format would incorrectly annotate 0-argument
Objective-C selector names as TT_TrailingAnnotation:

```
% echo "-(void)foo;" > /tmp/test.m
% ./bin/clang-format -debug /tmp/test.m
Language: Objective-C

Line(0, FSC=0): minus[T=68, OC=0] l_paren[T=68, OC=1] void[T=68, OC=2]
r_paren[T=68, OC=6] identifier[T=68, OC=7] semi[T=68, OC=10]
Line(0, FSC=0): eof[T=68, OC=0]
Run 0...
AnnotatedTokens(L=0):
 M=0 C=0 T=ObjCMethodSpecifier S=1 B=0 BK=0 P=0 Name=minus L=1 PPK=2
 FakeLParens= FakeRParens=0 Text='-'
 M=0 C=1 T=Unknown S=1 B=0 BK=0 P=33 Name=l_paren L=3 PPK=2
 FakeLParens= FakeRParens=0 Text='('
 M=0 C=1 T=Unknown S=0 B=0 BK=0 P=140 Name=void L=7 PPK=2 FakeLParens=
 FakeRParens=0 Text='void'
 M=0 C=0 T=CastRParen S=0 B=0 BK=0 P=43 Name=r_paren L=8 PPK=2
 FakeLParens= FakeRParens=0 Text=')'
 M=0 C=1 T=TrailingAnnotation S=0 B=0 BK=0 P=120 Name=identifier L=11
 PPK=2 FakeLParens= FakeRParens=0 Text='foo'
 M=0 C=0 T=Unknown S=0 B=0 BK=0 P=23 Name=semi L=12 PPK=2 FakeLParens=
 FakeRParens=0 Text=';'
```

This caused us to incorrectly indent 0-argument wrapped selectors
when Style.IndentWrappedFunctionNames was false, as we thought
the 0-argument ObjC selector name was actually a trailing
annotation (which is always indented).

This diff fixes the issue and adds tests.

Test Plan: New tests added. Confirmed tests failed before diff.
  After diff, tests passed. Ran tests with:
  % make -j12 FormatTests &&
  ./tools/clang/unittests/Format/FormatTests

Reviewers: djasper, jolesiak

Reviewed By: djasper, jolesiak

Subscribers: klimek, cfe-commits

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

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

Modified: cfe/trunk/lib/Format/TokenAnnotator.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/TokenAnnotator.cpp?rev=329297&r1=329296&r2=329297&view=diff
==
--- cfe/trunk/lib/Format/TokenAnnotator.cpp (original)
+++ cfe/trunk/lib/Format/TokenAnnotator.cpp Thu Apr  5 08:26:23 2018
@@ -391,6 +391,7 @@ private:
  Parent->isOneOf(tok::colon, tok::l_square, tok::l_paren,
  tok::kw_return, tok::kw_throw) ||
  Parent->isUnaryOperator() ||
+ // FIXME(bug 36976): ObjC return types shouldn't use TT_CastRParen.
  Parent->isOneOf(TT_ObjCForIn, TT_CastRParen) ||
  getBinOpPrecedence(Parent->Tok.getKind(), true, true) > 
prec::Unknown);
 bool ColonFound = false;
@@ -524,6 +525,7 @@ private:
   Left->ParameterCount = 0;
   Contexts.back().ColonIsObjCMethodExpr = true;
   if (Parent && Parent->is(tok::r_paren))
+// FIXME(bug 36976): ObjC return types shouldn't use TT_CastRParen.
 Parent->Type = TT_CastRParen;
 }
 ColonFound = true;
@@ -676,6 +678,7 @@ private:
 Tok->Type = TT_ObjCMethodExpr;
 const FormatToken *BeforePrevious = Tok->Previous->Previous;
 if (!BeforePrevious ||
+// FIXME(bug 36976): ObjC return types shouldn't use TT_CastRParen.
 !(BeforePrevious->is(TT_CastRParen) ||
   (BeforePrevious->is(TT_ObjCMethodExpr) &&
BeforePrevious->is(tok::colon))) ||
@@ -1343,6 +1346,17 @@ private:
  TT_LeadingJavaAnnotation)) {
 Current.Type = Current.Previous->Type;
   }
+} else if (Current.isOneOf(tok::identifier, tok::kw_new) &&
+   // FIXME(bug 36976): ObjC return types shouldn't use 
TT_CastRParen.
+   Current.Previous && Current.Previous->is(TT_CastRParen) &&
+   Current.Previous->MatchingParen &&
+   Current.Previous->MatchingParen->Previous &&
+   Current.Previous->MatchingParen->Previous->is(
+   TT_ObjCMethodSpecifier)) {
+  // This is the first part of an Objective-C selector name. (If there's no
+  // colon after this, this is the only place which annotates the 
identifier
+  // as a selector.)
+  Current.Type = TT_SelectorName;
 } else if (Current.isOneOf(tok::identifier, tok::kw_const) &&
Current.Previous &&
!Current.Previous->isOneOf(tok::equal, tok::at) &&

Modified: cfe/trunk/unittests/Format/FormatTestObjC.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTestObjC.cpp?rev=329297&r1=329296&r2=329297&view=diff
==
--- cfe/trunk/unittests/Format/FormatTestObjC.cpp (original)
+++ cfe/trunk/unittests/Format/FormatTestObjC.cpp Thu Apr  5 08:26:23 2018
@@ -523,6 +523,23 @@ TEST_F(FormatTestObjC, FormatObjCMe

r329298 - [clang-format] Support lightweight Objective-C generics

2018-04-05 Thread Ben Hamilton via cfe-commits
Author: benhamilton
Date: Thu Apr  5 08:26:25 2018
New Revision: 329298

URL: http://llvm.org/viewvc/llvm-project?rev=329298&view=rev
Log:
[clang-format] Support lightweight Objective-C generics

Summary:
Previously, `clang-format` didn't understand lightweight
Objective-C generics, which have the form:

```
@interface Foo , ... > ...
```

The lightweight generic specifier list appears before the base
class, if present, but because it starts with < like the protocol
specifier list, `UnwrappedLineParser` was getting confused and
failed to parse interfaces with both generics and protocol lists:

```
@interface Foo  : NSObject 
```

Since the parsed line would be incomplete, the format result
would be very confused (e.g., https://bugs.llvm.org/show_bug.cgi?id=24381).

This fixes the issue by explicitly parsing the ObjC lightweight
generic conformance list, so the line is fully parsed.

Fixes: https://bugs.llvm.org/show_bug.cgi?id=24381

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

Reviewers: djasper, jolesiak

Reviewed By: djasper

Subscribers: klimek, cfe-commits

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

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

Modified: cfe/trunk/lib/Format/UnwrappedLineParser.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/UnwrappedLineParser.cpp?rev=329298&r1=329297&r2=329298&view=diff
==
--- cfe/trunk/lib/Format/UnwrappedLineParser.cpp (original)
+++ cfe/trunk/lib/Format/UnwrappedLineParser.cpp Thu Apr  5 08:26:25 2018
@@ -2122,9 +2122,13 @@ void UnwrappedLineParser::parseRecord(bo
 
 void UnwrappedLineParser::parseObjCProtocolList() {
   assert(FormatTok->Tok.is(tok::less) && "'<' expected.");
-  do
+  do {
 nextToken();
-  while (!eof() && FormatTok->Tok.isNot(tok::greater));
+// Early exit in case someone forgot a close angle.
+if (FormatTok->isOneOf(tok::semi, tok::l_brace) ||
+FormatTok->Tok.isObjCAtKeyword(tok::objc_end))
+  return;
+  } while (!eof() && FormatTok->Tok.isNot(tok::greater));
   nextToken(); // Skip '>'.
 }
 
@@ -2155,7 +2159,32 @@ void UnwrappedLineParser::parseObjCInter
   nextToken();
   nextToken(); // interface name
 
-  // @interface can be followed by either a base class, or a category.
+  // @interface can be followed by a lightweight generic
+  // specialization list, then either a base class or a category.
+  if (FormatTok->Tok.is(tok::less)) {
+// Unlike protocol lists, generic parameterizations support
+// nested angles:
+//
+// @interface Foo> :
+// NSObject 
+//
+// so we need to count how many open angles we have left.
+unsigned NumOpenAngles = 1;
+do {
+  nextToken();
+  // Early exit in case someone forgot a close angle.
+  if (FormatTok->isOneOf(tok::semi, tok::l_brace) ||
+  FormatTok->Tok.isObjCAtKeyword(tok::objc_end))
+break;
+  if (FormatTok->Tok.is(tok::less))
+++NumOpenAngles;
+  else if (FormatTok->Tok.is(tok::greater)) {
+assert(NumOpenAngles > 0 && "'>' makes NumOpenAngles negative");
+--NumOpenAngles;
+  }
+} while (!eof() && NumOpenAngles != 0);
+nextToken(); // Skip '>'.
+  }
   if (FormatTok->Tok.is(tok::colon)) {
 nextToken();
 nextToken(); // base class name

Modified: cfe/trunk/unittests/Format/FormatTestObjC.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTestObjC.cpp?rev=329298&r1=329297&r2=329298&view=diff
==
--- cfe/trunk/unittests/Format/FormatTestObjC.cpp (original)
+++ cfe/trunk/unittests/Format/FormatTestObjC.cpp Thu Apr  5 08:26:25 2018
@@ -299,6 +299,18 @@ TEST_F(FormatTestObjC, FormatObjCInterfa
"+ (id)init;\n"
"@end");
 
+  verifyFormat("@interface Foo  : Bar  {\n"
+   "  int _i;\n"
+   "}\n"
+   "+ (id)init;\n"
+   "@end");
+
+  verifyFormat("@interface Foo > : Xyzzy  {\n"
+   "  int _i;\n"
+   "}\n"
+   "+ (id)init;\n"
+   "@end");
+
   verifyFormat("@interface Foo (HackStuff) {\n"
"  int _i;\n"
"}\n"


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


[PATCH] D44996: [clang-format] Ensure ObjC selectors with 0 args are annotated correctly

2018-04-05 Thread Ben Hamilton via Phabricator via cfe-commits
benhamilton updated this revision to Diff 141161.
benhamilton added a comment.

Add FIXME comments.


Repository:
  rC Clang

https://reviews.llvm.org/D44996

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


Index: unittests/Format/FormatTestObjC.cpp
===
--- unittests/Format/FormatTestObjC.cpp
+++ unittests/Format/FormatTestObjC.cpp
@@ -523,6 +523,23 @@
   verifyFormat("- (void)drawRectOn:(id)surface\n"
"ofSize:(size_t)height\n"
"  :(size_t)width;");
+  Style.ColumnLimit = 40;
+  // Make sure selectors with 0, 1, or more arguments are not indented
+  // when IndentWrappedFunctionNames is false.
+  Style.IndentWrappedFunctionNames = false;
+  verifyFormat("- (a)\n"
+   ";\n");
+  verifyFormat("- (a)\n"
+   ":(int)a;\n");
+  verifyFormat("- (a)\n"
+   ":(int)a\n"
+   ":(int)a;\n");
+  verifyFormat("- (a)\n"
+   " aaa:(int)a\n"
+   ":(int)a;\n");
+  verifyFormat("- (a)\n"
+   ":(int)a\n"
+   " aaa:(int)a;\n");
 
   // Continuation indent width should win over aligning colons if the function
   // name is long.
Index: lib/Format/TokenAnnotator.cpp
===
--- lib/Format/TokenAnnotator.cpp
+++ lib/Format/TokenAnnotator.cpp
@@ -391,6 +391,7 @@
  Parent->isOneOf(tok::colon, tok::l_square, tok::l_paren,
  tok::kw_return, tok::kw_throw) ||
  Parent->isUnaryOperator() ||
+ // FIXME(bug 36976): ObjC return types shouldn't use TT_CastRParen.
  Parent->isOneOf(TT_ObjCForIn, TT_CastRParen) ||
  getBinOpPrecedence(Parent->Tok.getKind(), true, true) > 
prec::Unknown);
 bool ColonFound = false;
@@ -524,6 +525,7 @@
   Left->ParameterCount = 0;
   Contexts.back().ColonIsObjCMethodExpr = true;
   if (Parent && Parent->is(tok::r_paren))
+// FIXME(bug 36976): ObjC return types shouldn't use TT_CastRParen.
 Parent->Type = TT_CastRParen;
 }
 ColonFound = true;
@@ -676,6 +678,7 @@
 Tok->Type = TT_ObjCMethodExpr;
 const FormatToken *BeforePrevious = Tok->Previous->Previous;
 if (!BeforePrevious ||
+// FIXME(bug 36976): ObjC return types shouldn't use TT_CastRParen.
 !(BeforePrevious->is(TT_CastRParen) ||
   (BeforePrevious->is(TT_ObjCMethodExpr) &&
BeforePrevious->is(tok::colon))) ||
@@ -1343,6 +1346,17 @@
  TT_LeadingJavaAnnotation)) {
 Current.Type = Current.Previous->Type;
   }
+} else if (Current.isOneOf(tok::identifier, tok::kw_new) &&
+   // FIXME(bug 36976): ObjC return types shouldn't use 
TT_CastRParen.
+   Current.Previous && Current.Previous->is(TT_CastRParen) &&
+   Current.Previous->MatchingParen &&
+   Current.Previous->MatchingParen->Previous &&
+   Current.Previous->MatchingParen->Previous->is(
+   TT_ObjCMethodSpecifier)) {
+  // This is the first part of an Objective-C selector name. (If there's no
+  // colon after this, this is the only place which annotates the 
identifier
+  // as a selector.)
+  Current.Type = TT_SelectorName;
 } else if (Current.isOneOf(tok::identifier, tok::kw_const) &&
Current.Previous &&
!Current.Previous->isOneOf(tok::equal, tok::at) &&


Index: unittests/Format/FormatTestObjC.cpp
===
--- unittests/Format/FormatTestObjC.cpp
+++ unittests/Format/FormatTestObjC.cpp
@@ -523,6 +523,23 @@
   verifyFormat("- (void)drawRectOn:(id)surface\n"
"ofSize:(size_t)height\n"
"  :(size_t)width;");
+  Style.ColumnLimit = 40;
+  // Make sure selectors with 0, 1, or more arguments are not indented
+  // when IndentWrappedFunctionNames is false.
+  Style.IndentWrappedFunctionNames = false;
+  verifyFormat("- (a)\n"
+   ";\n");
+  verifyFormat("- (a)\n"
+   ":(int)a;\n");
+  verifyFormat("- (a)\n"
+   ":(int)a\n"
+   ":(int)a;\n");
+  verifyFormat("- (a)\n"
+   " 

[PATCH] D45185: [clang-format] Support lightweight Objective-C generics

2018-04-05 Thread Ben Hamilton via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC329298: [clang-format] Support lightweight Objective-C 
generics (authored by benhamilton, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D45185?vs=140968&id=141163#toc

Repository:
  rC Clang

https://reviews.llvm.org/D45185

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


Index: unittests/Format/FormatTestObjC.cpp
===
--- unittests/Format/FormatTestObjC.cpp
+++ unittests/Format/FormatTestObjC.cpp
@@ -299,6 +299,18 @@
"+ (id)init;\n"
"@end");
 
+  verifyFormat("@interface Foo  : Bar  {\n"
+   "  int _i;\n"
+   "}\n"
+   "+ (id)init;\n"
+   "@end");
+
+  verifyFormat("@interface Foo > : Xyzzy  {\n"
+   "  int _i;\n"
+   "}\n"
+   "+ (id)init;\n"
+   "@end");
+
   verifyFormat("@interface Foo (HackStuff) {\n"
"  int _i;\n"
"}\n"
Index: lib/Format/UnwrappedLineParser.cpp
===
--- lib/Format/UnwrappedLineParser.cpp
+++ lib/Format/UnwrappedLineParser.cpp
@@ -2122,9 +2122,13 @@
 
 void UnwrappedLineParser::parseObjCProtocolList() {
   assert(FormatTok->Tok.is(tok::less) && "'<' expected.");
-  do
+  do {
 nextToken();
-  while (!eof() && FormatTok->Tok.isNot(tok::greater));
+// Early exit in case someone forgot a close angle.
+if (FormatTok->isOneOf(tok::semi, tok::l_brace) ||
+FormatTok->Tok.isObjCAtKeyword(tok::objc_end))
+  return;
+  } while (!eof() && FormatTok->Tok.isNot(tok::greater));
   nextToken(); // Skip '>'.
 }
 
@@ -2155,7 +2159,32 @@
   nextToken();
   nextToken(); // interface name
 
-  // @interface can be followed by either a base class, or a category.
+  // @interface can be followed by a lightweight generic
+  // specialization list, then either a base class or a category.
+  if (FormatTok->Tok.is(tok::less)) {
+// Unlike protocol lists, generic parameterizations support
+// nested angles:
+//
+// @interface Foo> :
+// NSObject 
+//
+// so we need to count how many open angles we have left.
+unsigned NumOpenAngles = 1;
+do {
+  nextToken();
+  // Early exit in case someone forgot a close angle.
+  if (FormatTok->isOneOf(tok::semi, tok::l_brace) ||
+  FormatTok->Tok.isObjCAtKeyword(tok::objc_end))
+break;
+  if (FormatTok->Tok.is(tok::less))
+++NumOpenAngles;
+  else if (FormatTok->Tok.is(tok::greater)) {
+assert(NumOpenAngles > 0 && "'>' makes NumOpenAngles negative");
+--NumOpenAngles;
+  }
+} while (!eof() && NumOpenAngles != 0);
+nextToken(); // Skip '>'.
+  }
   if (FormatTok->Tok.is(tok::colon)) {
 nextToken();
 nextToken(); // base class name


Index: unittests/Format/FormatTestObjC.cpp
===
--- unittests/Format/FormatTestObjC.cpp
+++ unittests/Format/FormatTestObjC.cpp
@@ -299,6 +299,18 @@
"+ (id)init;\n"
"@end");
 
+  verifyFormat("@interface Foo  : Bar  {\n"
+   "  int _i;\n"
+   "}\n"
+   "+ (id)init;\n"
+   "@end");
+
+  verifyFormat("@interface Foo > : Xyzzy  {\n"
+   "  int _i;\n"
+   "}\n"
+   "+ (id)init;\n"
+   "@end");
+
   verifyFormat("@interface Foo (HackStuff) {\n"
"  int _i;\n"
"}\n"
Index: lib/Format/UnwrappedLineParser.cpp
===
--- lib/Format/UnwrappedLineParser.cpp
+++ lib/Format/UnwrappedLineParser.cpp
@@ -2122,9 +2122,13 @@
 
 void UnwrappedLineParser::parseObjCProtocolList() {
   assert(FormatTok->Tok.is(tok::less) && "'<' expected.");
-  do
+  do {
 nextToken();
-  while (!eof() && FormatTok->Tok.isNot(tok::greater));
+// Early exit in case someone forgot a close angle.
+if (FormatTok->isOneOf(tok::semi, tok::l_brace) ||
+FormatTok->Tok.isObjCAtKeyword(tok::objc_end))
+  return;
+  } while (!eof() && FormatTok->Tok.isNot(tok::greater));
   nextToken(); // Skip '>'.
 }
 
@@ -2155,7 +2159,32 @@
   nextToken();
   nextToken(); // interface name
 
-  // @interface can be followed by either a base class, or a category.
+  // @interface can be followed by a lightweight generic
+  // specialization list, then either a base class or a category.
+  if (FormatTok->Tok.is(tok::less)) {
+// Unlike protocol lists, generic parameterizations support
+// nested angles:
+//
+// @interface Foo> :
+// NSObject 
+//
+// so we need to count how many open angles we have left.
+unsigned NumOpenAngles = 1;
+do {
+  nextToken();
+  // Early exit in case someone forg

[PATCH] D44996: [clang-format] Ensure ObjC selectors with 0 args are annotated correctly

2018-04-05 Thread Ben Hamilton via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC329297: [clang-format] Ensure ObjC selectors with 0 args are 
annotated correctly (authored by benhamilton, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D44996?vs=141161&id=141162#toc

Repository:
  rC Clang

https://reviews.llvm.org/D44996

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


Index: lib/Format/TokenAnnotator.cpp
===
--- lib/Format/TokenAnnotator.cpp
+++ lib/Format/TokenAnnotator.cpp
@@ -391,6 +391,7 @@
  Parent->isOneOf(tok::colon, tok::l_square, tok::l_paren,
  tok::kw_return, tok::kw_throw) ||
  Parent->isUnaryOperator() ||
+ // FIXME(bug 36976): ObjC return types shouldn't use TT_CastRParen.
  Parent->isOneOf(TT_ObjCForIn, TT_CastRParen) ||
  getBinOpPrecedence(Parent->Tok.getKind(), true, true) > 
prec::Unknown);
 bool ColonFound = false;
@@ -524,6 +525,7 @@
   Left->ParameterCount = 0;
   Contexts.back().ColonIsObjCMethodExpr = true;
   if (Parent && Parent->is(tok::r_paren))
+// FIXME(bug 36976): ObjC return types shouldn't use TT_CastRParen.
 Parent->Type = TT_CastRParen;
 }
 ColonFound = true;
@@ -676,6 +678,7 @@
 Tok->Type = TT_ObjCMethodExpr;
 const FormatToken *BeforePrevious = Tok->Previous->Previous;
 if (!BeforePrevious ||
+// FIXME(bug 36976): ObjC return types shouldn't use TT_CastRParen.
 !(BeforePrevious->is(TT_CastRParen) ||
   (BeforePrevious->is(TT_ObjCMethodExpr) &&
BeforePrevious->is(tok::colon))) ||
@@ -1343,6 +1346,17 @@
  TT_LeadingJavaAnnotation)) {
 Current.Type = Current.Previous->Type;
   }
+} else if (Current.isOneOf(tok::identifier, tok::kw_new) &&
+   // FIXME(bug 36976): ObjC return types shouldn't use 
TT_CastRParen.
+   Current.Previous && Current.Previous->is(TT_CastRParen) &&
+   Current.Previous->MatchingParen &&
+   Current.Previous->MatchingParen->Previous &&
+   Current.Previous->MatchingParen->Previous->is(
+   TT_ObjCMethodSpecifier)) {
+  // This is the first part of an Objective-C selector name. (If there's no
+  // colon after this, this is the only place which annotates the 
identifier
+  // as a selector.)
+  Current.Type = TT_SelectorName;
 } else if (Current.isOneOf(tok::identifier, tok::kw_const) &&
Current.Previous &&
!Current.Previous->isOneOf(tok::equal, tok::at) &&
Index: unittests/Format/FormatTestObjC.cpp
===
--- unittests/Format/FormatTestObjC.cpp
+++ unittests/Format/FormatTestObjC.cpp
@@ -523,6 +523,23 @@
   verifyFormat("- (void)drawRectOn:(id)surface\n"
"ofSize:(size_t)height\n"
"  :(size_t)width;");
+  Style.ColumnLimit = 40;
+  // Make sure selectors with 0, 1, or more arguments are not indented
+  // when IndentWrappedFunctionNames is false.
+  Style.IndentWrappedFunctionNames = false;
+  verifyFormat("- (a)\n"
+   ";\n");
+  verifyFormat("- (a)\n"
+   ":(int)a;\n");
+  verifyFormat("- (a)\n"
+   ":(int)a\n"
+   ":(int)a;\n");
+  verifyFormat("- (a)\n"
+   " aaa:(int)a\n"
+   ":(int)a;\n");
+  verifyFormat("- (a)\n"
+   ":(int)a\n"
+   " aaa:(int)a;\n");
 
   // Continuation indent width should win over aligning colons if the function
   // name is long.


Index: lib/Format/TokenAnnotator.cpp
===
--- lib/Format/TokenAnnotator.cpp
+++ lib/Format/TokenAnnotator.cpp
@@ -391,6 +391,7 @@
  Parent->isOneOf(tok::colon, tok::l_square, tok::l_paren,
  tok::kw_return, tok::kw_throw) ||
  Parent->isUnaryOperator() ||
+ // FIXME(bug 36976): ObjC return types shouldn't use TT_CastRParen.
  Parent->isOneOf(TT_ObjCForIn, TT_CastRParen) ||
  getBinOpPrecedence(Parent->Tok.getKind(), true, true) > prec::Unknown);
 bool ColonFound = false;
@@ -524,6 +525,7 @@
   Left->ParameterCount = 0;
   Contexts.back().ColonIsObjCMethodExpr = true;
   if (Parent && Parent->is(tok::r_paren))
+// FIXME(bug 36976): ObjC return types shouldn

r329300 - Disable -fmerge-all-constants as default.

2018-04-05 Thread Manoj Gupta via cfe-commits
Author: manojgupta
Date: Thu Apr  5 08:29:52 2018
New Revision: 329300

URL: http://llvm.org/viewvc/llvm-project?rev=329300&view=rev
Log:
Disable -fmerge-all-constants as default.

Summary:
"-fmerge-all-constants" is a non-conforming optimization and should not
be the default. It is also causing miscompiles when building Linux
Kernel (https://lkml.org/lkml/2018/3/20/872).

Fixes PR18538.

Reviewers: rjmccall, rsmith, chandlerc

Reviewed By: rsmith, chandlerc

Subscribers: srhines, cfe-commits

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

Modified:
cfe/trunk/include/clang/Driver/Options.td
cfe/trunk/lib/AST/ExprConstant.cpp
cfe/trunk/lib/Driver/ToolChains/Clang.cpp
cfe/trunk/lib/Frontend/CompilerInvocation.cpp
cfe/trunk/test/CodeGen/array-init.c
cfe/trunk/test/CodeGen/decl.c
cfe/trunk/test/CodeGenCXX/const-init-cxx11.cpp
cfe/trunk/test/CodeGenCXX/cxx0x-initializer-references.cpp
cfe/trunk/test/CodeGenCXX/cxx0x-initializer-stdinitializerlist.cpp
cfe/trunk/test/CodeGenObjCXX/arc-cxx11-init-list.mm
cfe/trunk/test/Driver/clang_f_opts.c

Modified: cfe/trunk/include/clang/Driver/Options.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Options.td?rev=329300&r1=329299&r2=329300&view=diff
==
--- cfe/trunk/include/clang/Driver/Options.td (original)
+++ cfe/trunk/include/clang/Driver/Options.td Thu Apr  5 08:29:52 2018
@@ -1133,7 +1133,8 @@ def fthinlto_index_EQ : Joined<["-"], "f
   HelpText<"Perform ThinLTO importing using provided function summary index">;
 def fmacro_backtrace_limit_EQ : Joined<["-"], "fmacro-backtrace-limit=">,
 Group, Flags<[DriverOption, 
CoreOption]>;
-def fmerge_all_constants : Flag<["-"], "fmerge-all-constants">, Group;
+def fmerge_all_constants : Flag<["-"], "fmerge-all-constants">, Group,
+  Flags<[CC1Option]>, HelpText<"Allow merging of constants">;
 def fmessage_length_EQ : Joined<["-"], "fmessage-length=">, Group;
 def fms_extensions : Flag<["-"], "fms-extensions">, Group, 
Flags<[CC1Option, CoreOption]>,
   HelpText<"Accept some non-standard constructs supported by the Microsoft 
compiler">;
@@ -1282,7 +1283,7 @@ def fveclib : Joined<["-"], "fveclib=">,
 def fno_lax_vector_conversions : Flag<["-"], "fno-lax-vector-conversions">, 
Group,
   HelpText<"Disallow implicit conversions between vectors with a different 
number of elements or different element types">, Flags<[CC1Option]>;
 def fno_merge_all_constants : Flag<["-"], "fno-merge-all-constants">, 
Group,
-Flags<[CC1Option]>, HelpText<"Disallow merging of constants">;
+  HelpText<"Disallow merging of constants">;
 def fno_modules : Flag <["-"], "fno-modules">, Group,
   Flags<[DriverOption]>;
 def fno_implicit_module_maps : Flag <["-"], "fno-implicit-module-maps">, 
Group,

Modified: cfe/trunk/lib/AST/ExprConstant.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ExprConstant.cpp?rev=329300&r1=329299&r2=329300&view=diff
==
--- cfe/trunk/lib/AST/ExprConstant.cpp (original)
+++ cfe/trunk/lib/AST/ExprConstant.cpp Thu Apr  5 08:29:52 2018
@@ -8596,9 +8596,6 @@ bool IntExprEvaluator::VisitBinaryOperat
 (LHSValue.Base && isZeroSized(RHSValue)))
   return Error(E);
 // Pointers with different bases cannot represent the same object.
-// (Note that clang defaults to -fmerge-all-constants, which can
-// lead to inconsistent results for comparisons involving the address
-// of a constant; this generally doesn't matter in practice.)
 return Success(E->getOpcode() == BO_NE, E);
   }
 

Modified: cfe/trunk/lib/Driver/ToolChains/Clang.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Clang.cpp?rev=329300&r1=329299&r2=329300&view=diff
==
--- cfe/trunk/lib/Driver/ToolChains/Clang.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/Clang.cpp Thu Apr  5 08:29:52 2018
@@ -3361,9 +3361,9 @@ void Clang::ConstructJob(Compilation &C,
 
   Args.AddLastArg(CmdArgs, options::OPT_fveclib);
 
-  if (!Args.hasFlag(options::OPT_fmerge_all_constants,
-options::OPT_fno_merge_all_constants))
-CmdArgs.push_back("-fno-merge-all-constants");
+  if (Args.hasFlag(options::OPT_fmerge_all_constants,
+   options::OPT_fno_merge_all_constants, false))
+CmdArgs.push_back("-fmerge-all-constants");
 
   // LLVM Code Generator Options.
 

Modified: cfe/trunk/lib/Frontend/CompilerInvocation.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/CompilerInvocation.cpp?rev=329300&r1=329299&r2=329300&view=diff
==
--- cfe/trunk/lib/Frontend/CompilerInvocation.cpp (original)
+++ cfe/trunk/lib/Frontend/CompilerInv

r329301 - [ASTImporter] Fix for importing unnamed structs

2018-04-05 Thread Aleksei Sidorin via cfe-commits
Author: a.sidorin
Date: Thu Apr  5 08:31:49 2018
New Revision: 329301

URL: http://llvm.org/viewvc/llvm-project?rev=329301&view=rev
Log:
[ASTImporter] Fix for importing unnamed structs

Patch by Peter Szecsi!

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


Modified:
cfe/trunk/lib/AST/ASTImporter.cpp
cfe/trunk/lib/AST/ASTStructuralEquivalence.cpp
cfe/trunk/test/ASTMerge/struct/Inputs/struct1.c
cfe/trunk/test/ASTMerge/struct/Inputs/struct2.c
cfe/trunk/test/ASTMerge/struct/test.c

Modified: cfe/trunk/lib/AST/ASTImporter.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTImporter.cpp?rev=329301&r1=329300&r2=329301&view=diff
==
--- cfe/trunk/lib/AST/ASTImporter.cpp (original)
+++ cfe/trunk/lib/AST/ASTImporter.cpp Thu Apr  5 08:31:49 2018
@@ -1923,9 +1923,8 @@ Decl *ASTNodeImporter::VisitRecordDecl(R
   }
   
   if (RecordDecl *FoundRecord = dyn_cast(Found)) {
-if (D->isAnonymousStructOrUnion() && 
-FoundRecord->isAnonymousStructOrUnion()) {
-  // If both anonymous structs/unions are in a record context, make 
sure
+if (!SearchName) {
+  // If both unnamed structs/unions are in a record context, make sure
   // they occur in the same location in the context records.
   if (Optional Index1 =
   StructuralEquivalenceContext::findUntaggedStructOrUnionIndex(

Modified: cfe/trunk/lib/AST/ASTStructuralEquivalence.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTStructuralEquivalence.cpp?rev=329301&r1=329300&r2=329301&view=diff
==
--- cfe/trunk/lib/AST/ASTStructuralEquivalence.cpp (original)
+++ cfe/trunk/lib/AST/ASTStructuralEquivalence.cpp Thu Apr  5 08:31:49 2018
@@ -1256,6 +1256,10 @@ StructuralEquivalenceContext::findUntagg
 // If the field looks like this:
 // struct { ... } A;
 QualType FieldType = F->getType();
+// In case of nested structs.
+while (const auto *ElabType = dyn_cast(FieldType))
+  FieldType = ElabType->getNamedType();
+
 if (const auto *RecType = dyn_cast(FieldType)) {
   const RecordDecl *RecDecl = RecType->getDecl();
   if (RecDecl->getDeclContext() == Owner && !RecDecl->getIdentifier()) {

Modified: cfe/trunk/test/ASTMerge/struct/Inputs/struct1.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/ASTMerge/struct/Inputs/struct1.c?rev=329301&r1=329300&r2=329301&view=diff
==
--- cfe/trunk/test/ASTMerge/struct/Inputs/struct1.c (original)
+++ cfe/trunk/test/ASTMerge/struct/Inputs/struct1.c Thu Apr  5 08:31:49 2018
@@ -77,3 +77,65 @@ typedef struct {
 } S13;
 
 S13 x13;
+
+// Matches
+struct Unnamed {
+  union {
+struct {
+  int i;
+} S;
+struct {
+  float i;
+} R;
+  } U;
+} x14;
+
+// Matches
+struct DeepUnnamed {
+  union {
+union {
+  struct {
+long i;
+  } S;
+  struct {
+int i;
+  } R;
+} U1;
+union {
+  struct {
+long i;
+  } S;
+  struct {
+float i;
+  } T;
+} U2;
+  } U;
+  struct {
+long i;
+  } V;
+} x15;
+
+// Mismatch due to unnamed struct used internally
+struct DeepUnnamedError {
+  union {
+union {
+  struct {
+long i;
+  } S;
+  struct {
+int i;
+  } R;
+} U1;
+union {
+  struct {
+long i; // Mismatch here.
+  } S;
+  struct {
+float i;
+  } T;
+} U2;
+  } U;
+  struct {
+long i;
+  } V;
+} x16;

Modified: cfe/trunk/test/ASTMerge/struct/Inputs/struct2.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/ASTMerge/struct/Inputs/struct2.c?rev=329301&r1=329300&r2=329301&view=diff
==
--- cfe/trunk/test/ASTMerge/struct/Inputs/struct2.c (original)
+++ cfe/trunk/test/ASTMerge/struct/Inputs/struct2.c Thu Apr  5 08:31:49 2018
@@ -74,3 +74,65 @@ typedef struct {
 } S13;
 
 S13 x13;
+
+// Matches
+struct Unnamed {
+  union {
+struct {
+  int i;
+} S;
+struct {
+  float i;
+} R;
+  } U;
+} x14;
+
+// Matches
+struct DeepUnnamed {
+  union {
+union {
+  struct {
+long i;
+  } S;
+  struct {
+int i;
+  } R;
+} U1;
+union {
+  struct {
+long i;
+  } S;
+  struct {
+float i;
+  } T;
+} U2;
+  } U;
+  struct {
+long i;
+  } V;
+} x15;
+
+// Mismatch due to unnamed struct used internally
+struct DeepUnnamedError {
+  union {
+union {
+  struct {
+long i;
+  } S;
+  struct {
+int i;
+  } R;
+} U1;
+union {
+  struct {
+float i; // Mismatch here.
+  } S;
+  struct {
+float i;
+  } T;
+} U2;
+  } U;
+  struct {
+long i;
+  } V;
+} x1

[PATCH] D45289: Disable -fmerge-all-constants as default.

2018-04-05 Thread Manoj Gupta via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC329300: Disable -fmerge-all-constants as default. (authored 
by manojgupta, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D45289?vs=141081&id=141164#toc

Repository:
  rC Clang

https://reviews.llvm.org/D45289

Files:
  include/clang/Driver/Options.td
  lib/AST/ExprConstant.cpp
  lib/Driver/ToolChains/Clang.cpp
  lib/Frontend/CompilerInvocation.cpp
  test/CodeGen/array-init.c
  test/CodeGen/decl.c
  test/CodeGenCXX/const-init-cxx11.cpp
  test/CodeGenCXX/cxx0x-initializer-references.cpp
  test/CodeGenCXX/cxx0x-initializer-stdinitializerlist.cpp
  test/CodeGenObjCXX/arc-cxx11-init-list.mm
  test/Driver/clang_f_opts.c

Index: lib/Driver/ToolChains/Clang.cpp
===
--- lib/Driver/ToolChains/Clang.cpp
+++ lib/Driver/ToolChains/Clang.cpp
@@ -3361,9 +3361,9 @@
 
   Args.AddLastArg(CmdArgs, options::OPT_fveclib);
 
-  if (!Args.hasFlag(options::OPT_fmerge_all_constants,
-options::OPT_fno_merge_all_constants))
-CmdArgs.push_back("-fno-merge-all-constants");
+  if (Args.hasFlag(options::OPT_fmerge_all_constants,
+   options::OPT_fno_merge_all_constants, false))
+CmdArgs.push_back("-fmerge-all-constants");
 
   // LLVM Code Generator Options.
 
Index: lib/AST/ExprConstant.cpp
===
--- lib/AST/ExprConstant.cpp
+++ lib/AST/ExprConstant.cpp
@@ -8596,9 +8596,6 @@
 (LHSValue.Base && isZeroSized(RHSValue)))
   return Error(E);
 // Pointers with different bases cannot represent the same object.
-// (Note that clang defaults to -fmerge-all-constants, which can
-// lead to inconsistent results for comparisons involving the address
-// of a constant; this generally doesn't matter in practice.)
 return Success(E->getOpcode() == BO_NE, E);
   }
 
Index: lib/Frontend/CompilerInvocation.cpp
===
--- lib/Frontend/CompilerInvocation.cpp
+++ lib/Frontend/CompilerInvocation.cpp
@@ -605,7 +605,7 @@
   Args.hasFlag(OPT_ffine_grained_bitfield_accesses,
OPT_fno_fine_grained_bitfield_accesses, false);
   Opts.DwarfDebugFlags = Args.getLastArgValue(OPT_dwarf_debug_flags);
-  Opts.MergeAllConstants = !Args.hasArg(OPT_fno_merge_all_constants);
+  Opts.MergeAllConstants = Args.hasArg(OPT_fmerge_all_constants);
   Opts.NoCommon = Args.hasArg(OPT_fno_common);
   Opts.NoImplicitFloat = Args.hasArg(OPT_no_implicit_float);
   Opts.OptimizeSize = getOptimizationLevelSize(Args);
Index: include/clang/Driver/Options.td
===
--- include/clang/Driver/Options.td
+++ include/clang/Driver/Options.td
@@ -1133,7 +1133,8 @@
   HelpText<"Perform ThinLTO importing using provided function summary index">;
 def fmacro_backtrace_limit_EQ : Joined<["-"], "fmacro-backtrace-limit=">,
 Group, Flags<[DriverOption, CoreOption]>;
-def fmerge_all_constants : Flag<["-"], "fmerge-all-constants">, Group;
+def fmerge_all_constants : Flag<["-"], "fmerge-all-constants">, Group,
+  Flags<[CC1Option]>, HelpText<"Allow merging of constants">;
 def fmessage_length_EQ : Joined<["-"], "fmessage-length=">, Group;
 def fms_extensions : Flag<["-"], "fms-extensions">, Group, Flags<[CC1Option, CoreOption]>,
   HelpText<"Accept some non-standard constructs supported by the Microsoft compiler">;
@@ -1282,7 +1283,7 @@
 def fno_lax_vector_conversions : Flag<["-"], "fno-lax-vector-conversions">, Group,
   HelpText<"Disallow implicit conversions between vectors with a different number of elements or different element types">, Flags<[CC1Option]>;
 def fno_merge_all_constants : Flag<["-"], "fno-merge-all-constants">, Group,
-Flags<[CC1Option]>, HelpText<"Disallow merging of constants">;
+  HelpText<"Disallow merging of constants">;
 def fno_modules : Flag <["-"], "fno-modules">, Group,
   Flags<[DriverOption]>;
 def fno_implicit_module_maps : Flag <["-"], "fno-implicit-module-maps">, Group,
Index: test/Driver/clang_f_opts.c
===
--- test/Driver/clang_f_opts.c
+++ test/Driver/clang_f_opts.c
@@ -276,6 +276,7 @@
 // RUN: -fno-inline-small-functions -finline-small-functions  \
 // RUN: -fno-fat-lto-objects -ffat-lto-objects\
 // RUN: -fno-merge-constants -fmerge-constants\
+// RUN: -fno-merge-all-constants -fmerge-all-constants\
 // RUN: -fno-caller-saves -fcaller-saves  \
 // RUN: -fno-reorder-blocks -freorder-blocks  \
 // RUN: -fno-schedule-insns2 -fschedule-insns2\
@@ -522,3 +523,10 @@
 // RUN: %clang -### -S -f

[PATCH] D45289: Disable -fmerge-all-constants as default.

2018-04-05 Thread Manoj Gupta via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL329300: Disable -fmerge-all-constants as default. (authored 
by manojgupta, committed by ).
Herald added a subscriber: llvm-commits.

Repository:
  rL LLVM

https://reviews.llvm.org/D45289

Files:
  cfe/trunk/include/clang/Driver/Options.td
  cfe/trunk/lib/AST/ExprConstant.cpp
  cfe/trunk/lib/Driver/ToolChains/Clang.cpp
  cfe/trunk/lib/Frontend/CompilerInvocation.cpp
  cfe/trunk/test/CodeGen/array-init.c
  cfe/trunk/test/CodeGen/decl.c
  cfe/trunk/test/CodeGenCXX/const-init-cxx11.cpp
  cfe/trunk/test/CodeGenCXX/cxx0x-initializer-references.cpp
  cfe/trunk/test/CodeGenCXX/cxx0x-initializer-stdinitializerlist.cpp
  cfe/trunk/test/CodeGenObjCXX/arc-cxx11-init-list.mm
  cfe/trunk/test/Driver/clang_f_opts.c

Index: cfe/trunk/include/clang/Driver/Options.td
===
--- cfe/trunk/include/clang/Driver/Options.td
+++ cfe/trunk/include/clang/Driver/Options.td
@@ -1133,7 +1133,8 @@
   HelpText<"Perform ThinLTO importing using provided function summary index">;
 def fmacro_backtrace_limit_EQ : Joined<["-"], "fmacro-backtrace-limit=">,
 Group, Flags<[DriverOption, CoreOption]>;
-def fmerge_all_constants : Flag<["-"], "fmerge-all-constants">, Group;
+def fmerge_all_constants : Flag<["-"], "fmerge-all-constants">, Group,
+  Flags<[CC1Option]>, HelpText<"Allow merging of constants">;
 def fmessage_length_EQ : Joined<["-"], "fmessage-length=">, Group;
 def fms_extensions : Flag<["-"], "fms-extensions">, Group, Flags<[CC1Option, CoreOption]>,
   HelpText<"Accept some non-standard constructs supported by the Microsoft compiler">;
@@ -1282,7 +1283,7 @@
 def fno_lax_vector_conversions : Flag<["-"], "fno-lax-vector-conversions">, Group,
   HelpText<"Disallow implicit conversions between vectors with a different number of elements or different element types">, Flags<[CC1Option]>;
 def fno_merge_all_constants : Flag<["-"], "fno-merge-all-constants">, Group,
-Flags<[CC1Option]>, HelpText<"Disallow merging of constants">;
+  HelpText<"Disallow merging of constants">;
 def fno_modules : Flag <["-"], "fno-modules">, Group,
   Flags<[DriverOption]>;
 def fno_implicit_module_maps : Flag <["-"], "fno-implicit-module-maps">, Group,
Index: cfe/trunk/test/CodeGenCXX/cxx0x-initializer-references.cpp
===
--- cfe/trunk/test/CodeGenCXX/cxx0x-initializer-references.cpp
+++ cfe/trunk/test/CodeGenCXX/cxx0x-initializer-references.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -std=c++11 -S -triple armv7-none-eabi -emit-llvm -o - %s | FileCheck %s
+// RUN: %clang_cc1 -std=c++11 -S -triple armv7-none-eabi -fmerge-all-constants -emit-llvm -o - %s | FileCheck %s
 
 namespace reference {
   struct A {
Index: cfe/trunk/test/CodeGenCXX/cxx0x-initializer-stdinitializerlist.cpp
===
--- cfe/trunk/test/CodeGenCXX/cxx0x-initializer-stdinitializerlist.cpp
+++ cfe/trunk/test/CodeGenCXX/cxx0x-initializer-stdinitializerlist.cpp
@@ -1,5 +1,5 @@
-// RUN: %clang_cc1 -std=c++11 -triple x86_64-none-linux-gnu -emit-llvm -o - %s | FileCheck -check-prefixes=X86,CHECK %s
-// RUN: %clang_cc1 -std=c++11 -triple amdgcn-amd-amdhsa -DNO_TLS -emit-llvm -o - %s | FileCheck -check-prefixes=AMDGCN,CHECK %s
+// RUN: %clang_cc1 -std=c++11 -triple x86_64-none-linux-gnu -fmerge-all-constants -emit-llvm -o - %s | FileCheck -check-prefixes=X86,CHECK %s
+// RUN: %clang_cc1 -std=c++11 -triple amdgcn-amd-amdhsa -DNO_TLS -fmerge-all-constants -emit-llvm -o - %s | FileCheck -check-prefixes=AMDGCN,CHECK %s
 
 namespace std {
   typedef decltype(sizeof(int)) size_t;
Index: cfe/trunk/test/CodeGenCXX/const-init-cxx11.cpp
===
--- cfe/trunk/test/CodeGenCXX/const-init-cxx11.cpp
+++ cfe/trunk/test/CodeGenCXX/const-init-cxx11.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -w -triple x86_64-elf-gnu -emit-llvm -o - %s -std=c++11 | FileCheck %s
+// RUN: %clang_cc1 -w -fmerge-all-constants -triple x86_64-elf-gnu -emit-llvm -o - %s -std=c++11 | FileCheck %s
 
 // FIXME: The padding in all these objects should be zero-initialized.
 namespace StructUnion {
Index: cfe/trunk/test/CodeGen/decl.c
===
--- cfe/trunk/test/CodeGen/decl.c
+++ cfe/trunk/test/CodeGen/decl.c
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -w -emit-llvm < %s | FileCheck %s
+// RUN: %clang_cc1 -w -fmerge-all-constants -emit-llvm < %s | FileCheck %s
 
 // CHECK: @test1.x = internal constant [12 x i32] [i32 1
 // CHECK: @test2.x = private unnamed_addr constant [13 x i32] [i32 1,
Index: cfe/trunk/test/CodeGen/array-init.c
===
--- cfe/trunk/test/CodeGen/array-init.c
+++ cfe/trunk/test/CodeGen/array-init.c
@@ -1,8 +1,11 @@
-// RUN: %clang_cc1 %s -O0 -triple x86_64-unkn

[PATCH] D45285: [clangd-vscode] Update VScode dependencies

2018-04-05 Thread Marc-Andre Laperle via Phabricator via cfe-commits
malaperle added a comment.

Do we need to bump the version of the extension and do a new release or 
anything like that? Or leave this for later?


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D45285



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


[PATCH] D45285: [clangd-vscode] Update VScode dependencies

2018-04-05 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added a comment.

Do we really want to keep editor plugins in the repository?


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D45285



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


[PATCH] D45202: [X86] Replacing X86-specific floor and ceil vector intrinsics with generic LLVM intrinsics

2018-04-05 Thread Craig Topper via Phabricator via cfe-commits
craig.topper added a comment.

But it’s not really consistent because the mask is being removed early for the 
packed intrinsics, but late for the scalar intrinsics. Doesn’t it also 
introduce extra code for fast isel?


https://reviews.llvm.org/D45202



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


[PATCH] D45006: [Tooling] A CompilationDatabase wrapper that infers header commands.

2018-04-05 Thread Sam McCall via Phabricator via cfe-commits
sammccall updated this revision to Diff 141172.
sammccall added a comment.

Address cross-language issues in a more comprehensive way.
Prefers (potentially) same-language over cross-language, handles cross-language
flag transfers correctly using -x and handling (dropping) -std.


Repository:
  rC Clang

https://reviews.llvm.org/D45006

Files:
  include/clang/Tooling/CompilationDatabase.h
  lib/Tooling/CMakeLists.txt
  lib/Tooling/InterpolatingCompilationDatabase.cpp
  unittests/Tooling/CompilationDatabaseTest.cpp

Index: unittests/Tooling/CompilationDatabaseTest.cpp
===
--- unittests/Tooling/CompilationDatabaseTest.cpp
+++ unittests/Tooling/CompilationDatabaseTest.cpp
@@ -626,5 +626,115 @@
   EXPECT_EQ(2, Argc);
 }
 
+struct MemCDB : public CompilationDatabase {
+  using EntryMap = llvm::StringMap>;
+  EntryMap Entries;
+  MemCDB(const EntryMap &E) : Entries(E) {}
+
+  std::vector getCompileCommands(StringRef F) const override {
+auto Ret = Entries.lookup(F);
+return {Ret.begin(), Ret.end()};
+  }
+
+  std::vector getAllFiles() const override {
+std::vector Result;
+for (const auto &Entry : Entries)
+  Result.push_back(Entry.first());
+return Result;
+  }
+};
+
+class InterpolateTest : public ::testing::Test {
+protected:
+  // Adds an entry to the underlying compilation database.
+  // A flag is injected: -D , so the command used can be identified.
+  void add(llvm::StringRef File, llvm::StringRef Flags = "") {
+llvm::SmallVector Argv = {"clang", File, "-D", File};
+llvm::SplitString(Flags, Argv);
+llvm::SmallString<32> Dir;
+llvm::sys::path::system_temp_directory(false, Dir);
+Entries[path(File)].push_back(
+{Dir, path(File), {Argv.begin(), Argv.end()}, "foo.o"});
+  }
+
+  // Turn a unix path fragment (foo/bar.h) into a native path (C:\tmp\foo\bar.h)
+  std::string path(llvm::SmallString<32> File) {
+llvm::SmallString<32> Dir;
+llvm::sys::path::system_temp_directory(false, Dir);
+llvm::sys::path::native(File);
+llvm::SmallString<64> Result;
+llvm::sys::path::append(Result, Dir, File);
+return Result.str();
+  }
+
+  // Look up the command from a relative path, and return it in string form.
+  // The input file is not included in the returned command.
+  std::string getCommand(llvm::StringRef F) {
+auto Results =
+inferMissingCompileCommands(llvm::make_unique(Entries))
+->getCompileCommands(path(F));
+if (Results.empty())
+  return "none";
+// drop the input file argument, so tests don't have to deal with path().
+EXPECT_EQ(Results[0].CommandLine.back(), path(F))
+<< "Last arg should be the file";
+Results[0].CommandLine.pop_back();
+return llvm::join(Results[0].CommandLine, " ");
+  }
+
+  MemCDB::EntryMap Entries;
+};
+
+TEST_F(InterpolateTest, Nearby) {
+  add("dir/foo.cpp");
+  add("dir/bar.cpp");
+  add("an/other/foo.cpp");
+
+  // great: dir and name both match (prefix or full, case insensitive)
+  EXPECT_EQ(getCommand("dir/f.cpp"), "clang -D dir/foo.cpp");
+  EXPECT_EQ(getCommand("dir/FOO.cpp"), "clang -D dir/foo.cpp");
+  // no name match. prefer matching dir, break ties by alpha
+  EXPECT_EQ(getCommand("dir/a.cpp"), "clang -D dir/bar.cpp");
+  // an exact name match beats one segment of directory match
+  EXPECT_EQ(getCommand("some/other/bar.h"),
+"clang -D dir/bar.cpp -x c++-header");
+  // two segments of directory match beat a prefix name match
+  EXPECT_EQ(getCommand("an/other/b.cpp"), "clang -D an/other/foo.cpp");
+  // if nothing matches at all, we still get the closest alpha match
+  EXPECT_EQ(getCommand("below/some/obscure/path.cpp"),
+"clang -D an/other/foo.cpp");
+}
+
+TEST_F(InterpolateTest, Language) {
+  add("dir/foo.cpp", "-std=c++17");
+  add("dir/baz.cee", "-x c");
+
+  // .h is ambiguous, so we add explicit language flags
+  EXPECT_EQ(getCommand("foo.h"),
+"clang -D dir/foo.cpp -x c++-header -std c++17");
+  // and don't add -x if the inferred language is correct.
+  EXPECT_EQ(getCommand("foo.hpp"), "clang -D dir/foo.cpp -std c++17");
+  // respect -x if it's already there.
+  EXPECT_EQ(getCommand("baz.h"), "clang -D dir/baz.cee -x c-header");
+  // prefer a worse match with the right language
+  EXPECT_EQ(getCommand("foo.c"), "clang -D dir/baz.cee");
+  Entries.erase(path(StringRef("dir/baz.cee")));
+  // Now we transfer across languages, so drop -std too.
+  EXPECT_EQ(getCommand("foo.c"), "clang -D dir/foo.cpp");
+}
+
+TEST_F(InterpolateTest, Strip) {
+  add("dir/foo.cpp", "-o foo.o -Wall");
+  // the -o option and the input file are removed, but -Wall is preserved.
+  EXPECT_EQ(getCommand("dir/bar.cpp"), "clang -D dir/foo.cpp -Wall");
+}
+
+TEST_F(InterpolateTest, Case) {
+  add("FOO/BAR/BAZ/SHOUT.cc");
+  add("foo/bar/baz/quiet.cc");
+  // Case mismatches are completely ignored, so we choose the name match.
+  EXPECT_EQ(getCommand("foo/bar/baz/sho

[PATCH] D45004: [clang-format] New style option IndentWrappedObjCMethodNames

2018-04-05 Thread Daniel Jasper via Phabricator via cfe-commits
djasper added a comment.

I'd go to great lengths to avoid adding new config options and so I don't think 
this would be a bad trade-off to make.

Also, note that you might not actually have to change much. A FormatStyle 
already contains a reference to the FormatStyleSet it was created from and you 
can get the FormatStyle for a different language through that. It might just be 
a bit hacky and not easy to understand as is, but maybe there are easy 
abstractions that we could build around it.

At any rate, your proposal (always indenting for ObjC code) is also fine by me. 
Do you think that survey Google-style ObjC code is enough? What does Xcode do 
by default?


Repository:
  rC Clang

https://reviews.llvm.org/D45004



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


[PATCH] D43322: Diagnose cases of "return x" that should be "return std::move(x)" for efficiency

2018-04-05 Thread Arthur O'Dwyer via Phabricator via cfe-commits
Quuxplusone updated this revision to Diff 141174.
Quuxplusone added a comment.

Finally learned how to "make check-clang" and actually run the test in the 
correct environment. Had to add `-fcxx-exceptions` to the command lines at the 
top of that file, because the code uses `throw`.

@rsmith PTAL?


Repository:
  rC Clang

https://reviews.llvm.org/D43322

Files:
  include/clang/Basic/DiagnosticGroups.td
  include/clang/Basic/DiagnosticSemaKinds.td
  include/clang/Sema/Sema.h
  lib/Sema/SemaStmt.cpp
  test/SemaCXX/warn-return-std-move.cpp

Index: test/SemaCXX/warn-return-std-move.cpp
===
--- /dev/null
+++ test/SemaCXX/warn-return-std-move.cpp
@@ -0,0 +1,334 @@
+// RUN: %clang_cc1 -fsyntax-only -fcxx-exceptions -Wreturn-std-move -Wreturn-std-move-in-c++11 -std=c++14 -verify %s
+// RUN: %clang_cc1 -fsyntax-only -fcxx-exceptions -Wreturn-std-move -Wreturn-std-move-in-c++11 -std=c++14 -fdiagnostics-parseable-fixits %s 2>&1 | FileCheck %s
+
+// definitions for std::move
+namespace std {
+inline namespace foo {
+template  struct remove_reference { typedef T type; };
+template  struct remove_reference { typedef T type; };
+template  struct remove_reference { typedef T type; };
+
+template  typename remove_reference::type &&move(T &&t);
+} // namespace foo
+} // namespace std
+
+struct Instrument {
+Instrument() {}
+Instrument(Instrument&&) { /* MOVE */ }
+Instrument(const Instrument&) { /* COPY */ }
+};
+struct ConvertFromBase { Instrument i; };
+struct ConvertFromDerived { Instrument i; };
+struct Base {
+Instrument i;
+operator ConvertFromBase() const& { return ConvertFromBase{i}; }
+operator ConvertFromBase() && { return ConvertFromBase{std::move(i)}; }
+};
+struct Derived : public Base {
+operator ConvertFromDerived() const& { return ConvertFromDerived{i}; }
+operator ConvertFromDerived() && { return ConvertFromDerived{std::move(i)}; }
+};
+struct ConstructFromBase {
+Instrument i;
+ConstructFromBase(const Base& b): i(b.i) {}
+ConstructFromBase(Base&& b): i(std::move(b.i)) {}
+};
+struct ConstructFromDerived {
+Instrument i;
+ConstructFromDerived(const Derived& d): i(d.i) {}
+ConstructFromDerived(Derived&& d): i(std::move(d.i)) {}
+};
+
+struct TrivialInstrument {
+int i = 42;
+};
+struct ConvertFromTrivialBase { TrivialInstrument i; };
+struct ConvertFromTrivialDerived { TrivialInstrument i; };
+struct TrivialBase {
+TrivialInstrument i;
+operator ConvertFromTrivialBase() const& { return ConvertFromTrivialBase{i}; }
+operator ConvertFromTrivialBase() && { return ConvertFromTrivialBase{std::move(i)}; }
+};
+struct TrivialDerived : public TrivialBase {
+operator ConvertFromTrivialDerived() const& { return ConvertFromTrivialDerived{i}; }
+operator ConvertFromTrivialDerived() && { return ConvertFromTrivialDerived{std::move(i)}; }
+};
+struct ConstructFromTrivialBase {
+TrivialInstrument i;
+ConstructFromTrivialBase(const TrivialBase& b): i(b.i) {}
+ConstructFromTrivialBase(TrivialBase&& b): i(std::move(b.i)) {}
+};
+struct ConstructFromTrivialDerived {
+TrivialInstrument i;
+ConstructFromTrivialDerived(const TrivialDerived& d): i(d.i) {}
+ConstructFromTrivialDerived(TrivialDerived&& d): i(std::move(d.i)) {}
+};
+
+Derived test1() {
+Derived d1;
+return d1;  // ok
+}
+Base test2() {
+Derived d2;
+return d2;  // e1
+// expected-warning@-1{{will be copied despite being returned by name}}
+// expected-note@-2{{to avoid copying}}
+// CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:12-[[@LINE-3]]:14}:"std::move(d2)"
+}
+ConstructFromDerived test3() {
+Derived d3;
+return d3;  // e2-cxx11
+// expected-warning@-1{{would have been copied despite being returned by name}}
+// expected-note@-2{{to avoid copying on older compilers}}
+// CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:12-[[@LINE-3]]:14}:"std::move(d3)"
+}
+ConstructFromBase test4() {
+Derived d4;
+return d4;  // e3
+// expected-warning@-1{{will be copied despite being returned by name}}
+// expected-note@-2{{to avoid copying}}
+// CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:12-[[@LINE-3]]:14}:"std::move(d4)"
+}
+ConvertFromDerived test5() {
+Derived d5;
+return d5;  // e4
+// expected-warning@-1{{will be copied despite being returned by name}}
+// expected-note@-2{{to avoid copying}}
+// CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:12-[[@LINE-3]]:14}:"std::move(d5)"
+}
+ConvertFromBase test6() {
+Derived d6;
+return d6;  // e5
+// expected-warning@-1{{will be copied despite being returned by name}}
+// expected-note@-2{{to avoid copying}}
+// CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:12-[[@LINE-3]]:14}:"std::move(d6)"
+}
+
+// These test cases should not produce the warning.
+Derived ok1() { Derived d; return d; }
+Base ok2() { Derived d; return static_cast(d); }
+ConstructFromDerived ok3() { Derived d; return static_cast(d); }
+Const

[PATCH] D45202: [X86] Replacing X86-specific floor and ceil vector intrinsics with generic LLVM intrinsics

2018-04-05 Thread Craig Topper via Phabricator via cfe-commits
craig.topper added a comment.

There's a similar patch for sqrt here https://reviews.llvm.org/D41168  and it 
uses a scalar sqrt and insert element for the scalar case. I think we need a 
consistent direction here.


https://reviews.llvm.org/D45202



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


[PATCH] D45277: [CUDA] Add amdgpu sub archs

2018-04-05 Thread Artem Belevich via Phabricator via cfe-commits
tra added a comment.

I didn't get a chance to review the patch before it got committed.




Comment at: lib/Basic/Targets.cpp:161
+case CudaArch::GFX902:
+  return "320";
+case CudaArch::UNKNOWN:

Unless you're planning to guarantee 1:1 match to functionality provided by 
nvidia's sm_32, it would be prudent to use some other value for the macro so 
the source code has a way to tell these GPUs apart.

Another issue with this approach is that typical use pattern for __CUDA_ARCH__ 
is 
`#if __CUDA_ARCH__ >= XXX`. I don't expect that we'll always be able to 
maintain order across GPU architectures among NVIDIA and AMD GPUs. Perhaps for 
HIP compilation it would make more sense to define __CUDA_ARCH__ as 1 (this 
should serve as a legacy indication of device-side compilation) and define 
__HIP_ARCH__ to indicate which AMD GPU we're compiling for without accidentally 
enabling something that was intended for NVIDIA's GPUs only.


Repository:
  rC Clang

https://reviews.llvm.org/D45277



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


[PATCH] D44764: [clangd] Use operator<< to prevent printers issues in Gtest

2018-04-05 Thread Marc-Andre Laperle via Phabricator via cfe-commits
malaperle added a comment.

@sammccall Are you OK with the latest version? Thanks!


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D44764



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


[PATCH] D45004: [clang-format] New style option IndentWrappedObjCMethodNames

2018-04-05 Thread Ben Hamilton via Phabricator via cfe-commits
benhamilton added a comment.

> A FormatStyle already contains a reference to the FormatStyleSet it was 
> created from and you can get the FormatStyle for a different language through 
> that. It might just be a bit hacky and not easy to understand as is, but 
> maybe there are easy abstractions that we could build around it.

Hmm, I didn't know that. That would make a short-term hack easier.

> At any rate, your proposal (always indenting for ObjC code) is also fine by 
> me. Do you think that survey Google-style ObjC code is enough? What does 
> Xcode do by default?

Apple SDKs have no line length limit and don't wrap code as far as I can tell, 
so they don't hit this issue.

Xcode neither indents nor aligns colons by default. It does no code formatting 
at all as far as I can tell.

I guess the question is, are there other big clients of Objective-C formatting 
via clang-format besides Google? I looked at the existing public coding styles, 
and none of them appear to talk about this issue.


Repository:
  rC Clang

https://reviews.llvm.org/D45004



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


[PATCH] D45004: [clang-format] New style option IndentWrappedObjCMethodNames

2018-04-05 Thread Ben Hamilton via Phabricator via cfe-commits
benhamilton added a comment.

Actually, a slight correction. By default, Xcode has a "Line wrapping" setting 
under Preferences -> Text editing which says:

  [ X ] Wrap lines to editor width
   Indent wrapped lines by:  [4 ] Spaces

which suggests people using Xcode may expect indentation on wrapped lines by 
default.

It also has a "Syntax-aware indenting" feature including "Automatic indent 
for... :", but the colon indentation only seems to apply for method 
invocations, not method signatures.


Repository:
  rC Clang

https://reviews.llvm.org/D45004



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


[PATCH] D45004: [clang-format] New style option IndentWrappedObjCMethodNames

2018-04-05 Thread Ben Hamilton via Phabricator via cfe-commits
benhamilton added a comment.

> By default, Xcode has a "Line wrapping" setting

Ah, that appears to just be a visual thing. Xcode doesn't actually insert 
newlines into the source code.


Repository:
  rC Clang

https://reviews.llvm.org/D45004



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


r329323 - Fix typo in comment -fmath-errno=0 -> -fno-math-errno

2018-04-05 Thread Sam Clegg via cfe-commits
Author: sbc
Date: Thu Apr  5 10:44:08 2018
New Revision: 329323

URL: http://llvm.org/viewvc/llvm-project?rev=329323&view=rev
Log:
Fix typo in comment -fmath-errno=0 -> -fno-math-errno

The former is not a valid clang argument

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

Modified:
cfe/trunk/include/clang/Basic/Builtins.def

Modified: cfe/trunk/include/clang/Basic/Builtins.def
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Builtins.def?rev=329323&r1=329322&r2=329323&view=diff
==
--- cfe/trunk/include/clang/Basic/Builtins.def (original)
+++ cfe/trunk/include/clang/Basic/Builtins.def Thu Apr  5 10:44:08 2018
@@ -89,7 +89,7 @@
 //  S:N: -> similar to the s:N: attribute, but the function is like vscanf
 //  in that it accepts its arguments as a va_list rather than
 //  through an ellipsis
-//  e -> const, but only when -fmath-errno=0
+//  e -> const, but only when -fno-math-errno
 //  j -> returns_twice (like setjmp)
 //  u -> arguments are not evaluated for their side-effects
 //  FIXME: gcc has nonnull


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


[PATCH] D45102: Fix typo in comment -fmath-errno=0 -> -fno-math-errno

2018-04-05 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL329323: Fix typo in comment -fmath-errno=0 -> 
-fno-math-errno (authored by sbc, committed by ).
Herald added a subscriber: llvm-commits.

Repository:
  rL LLVM

https://reviews.llvm.org/D45102

Files:
  cfe/trunk/include/clang/Basic/Builtins.def


Index: cfe/trunk/include/clang/Basic/Builtins.def
===
--- cfe/trunk/include/clang/Basic/Builtins.def
+++ cfe/trunk/include/clang/Basic/Builtins.def
@@ -89,7 +89,7 @@
 //  S:N: -> similar to the s:N: attribute, but the function is like vscanf
 //  in that it accepts its arguments as a va_list rather than
 //  through an ellipsis
-//  e -> const, but only when -fmath-errno=0
+//  e -> const, but only when -fno-math-errno
 //  j -> returns_twice (like setjmp)
 //  u -> arguments are not evaluated for their side-effects
 //  FIXME: gcc has nonnull


Index: cfe/trunk/include/clang/Basic/Builtins.def
===
--- cfe/trunk/include/clang/Basic/Builtins.def
+++ cfe/trunk/include/clang/Basic/Builtins.def
@@ -89,7 +89,7 @@
 //  S:N: -> similar to the s:N: attribute, but the function is like vscanf
 //  in that it accepts its arguments as a va_list rather than
 //  through an ellipsis
-//  e -> const, but only when -fmath-errno=0
+//  e -> const, but only when -fno-math-errno
 //  j -> returns_twice (like setjmp)
 //  u -> arguments are not evaluated for their side-effects
 //  FIXME: gcc has nonnull
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D45233: [Driver] Update GCC libraries detection logic for Gentoo.

2018-04-05 Thread Manoj Gupta via Phabricator via cfe-commits
manojgupta updated this revision to Diff 141182.
manojgupta added a comment.

Updated tests and added a sysroot to test that LDLIBS are picked by
parsing /etc/env.d/gcc/tuple-version file.


Repository:
  rC Clang

https://reviews.llvm.org/D45233

Files:
  lib/Driver/ToolChains/Gnu.cpp
  lib/Driver/ToolChains/Gnu.h
  
test/Driver/Inputs/gentoo_linux_gcc_4.9.x_tree/etc/env.d/gcc/config-x86_64-pc-linux-gnu
  
test/Driver/Inputs/gentoo_linux_gcc_4.9.x_tree/etc/env.d/gcc/x86_64-pc-linux-gnu-4.9.3
  test/Driver/Inputs/gentoo_linux_gcc_4.9.x_tree/etc/gentoo-release
  test/Driver/Inputs/gentoo_linux_gcc_4.9.x_tree/usr/include/.keep
  
test/Driver/Inputs/gentoo_linux_gcc_4.9.x_tree/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.x/32/crtbegin.o
  
test/Driver/Inputs/gentoo_linux_gcc_4.9.x_tree/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.x/crtbegin.o
  
test/Driver/Inputs/gentoo_linux_gcc_4.9.x_tree/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.x/include/g++-v4.9.3/.keep
  
test/Driver/Inputs/gentoo_linux_gcc_4.9.x_tree/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.x/x32/crtbegin.o
  
test/Driver/Inputs/gentoo_linux_gcc_4.9.x_tree/usr/lib/gcc/x86_64-pc-linux-gnu/5.4.0/32/crtbegin.o
  
test/Driver/Inputs/gentoo_linux_gcc_4.9.x_tree/usr/lib/gcc/x86_64-pc-linux-gnu/5.4.0/crtbegin.o
  
test/Driver/Inputs/gentoo_linux_gcc_4.9.x_tree/usr/lib/gcc/x86_64-pc-linux-gnu/5.4.0/include/g++-v5.4.0/.keep
  
test/Driver/Inputs/gentoo_linux_gcc_4.9.x_tree/usr/lib/gcc/x86_64-pc-linux-gnu/5.4.0/x32/crtbegin.o
  
test/Driver/Inputs/gentoo_linux_gcc_4.9.x_tree/usr/x86_64-pc-linux-gnu/lib/.keep
  test/Driver/linux-header-search.cpp

Index: test/Driver/linux-header-search.cpp
===
--- test/Driver/linux-header-search.cpp
+++ test/Driver/linux-header-search.cpp
@@ -343,6 +343,59 @@
 // CHECK-GENTOO-4-9-3-32: "-internal-externc-isystem" "[[SYSROOT]]/include"
 // CHECK-GENTOO-4-9-3-32: "-internal-externc-isystem" "[[SYSROOT]]/usr/include"
 //
+// Test support for parsing Gentoo's gcc-config -- clang should parse the
+// /etc/env.d/gcc/config-x86_64-pc-linux-gnu file to find CURRENT gcc used.
+// Then should pick the multilibs from version 4.9.x specified in
+// /etc/env.d/gcc/x86_64-pc-linux-gnu-4.9.3.
+// RUN: %clang -no-canonical-prefixes %s -### -fsyntax-only 2>&1 \
+// RUN: -target x86_64-unknown-linux-gnu -stdlib=libstdc++ \
+// RUN: --sysroot=%S/Inputs/gentoo_linux_gcc_4.9.x_tree \
+// RUN: --gcc-toolchain="" \
+// RUN:   | FileCheck --check-prefix=CHECK-GENTOO-4-9-X %s
+//
+// CHECK-GENTOO-4-9-X: "{{.*}}clang{{.*}}" "-cc1"
+// CHECK-GENTOO-4-9-X: "-resource-dir" "[[RESOURCE_DIR:[^"]+]]"
+// CHECK-GENTOO-4-9-X: "-isysroot" "[[SYSROOT:[^"]+]]"
+// CHECK-GENTOO-4-9-X: "-internal-isystem" "[[SYSROOT]]/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.x/include/g++-v4.9.3"
+// CHECK-GENTOO-4-9-X: "-internal-isystem" "[[SYSROOT]]/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.x/include/g++-v4.9.3/x86_64-pc-linux-gnu"
+// CHECK-GENTOO-4-9-X: "-internal-isystem" "[[SYSROOT]]/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.x/include/g++-v4.9.3/backward"
+// CHECK-GENTOO-4-9-X: "-internal-isystem" "[[SYSROOT]]/usr/local/include"
+// CHECK-GENTOO-4-9-X: "-internal-isystem" "[[RESOURCE_DIR]]{{/|}}include"
+// CHECK-GENTOO-4-9-X: "-internal-externc-isystem" "[[SYSROOT]]/include"
+// CHECK-GENTOO-4-9-X: "-internal-externc-isystem" "[[SYSROOT]]/usr/include"
+//
+// RUN: %clang -no-canonical-prefixes %s -### -fsyntax-only 2>&1 \
+// RUN: -target x86_64-unknown-linux-gnux32 -stdlib=libstdc++ \
+// RUN: --sysroot=%S/Inputs/gentoo_linux_gcc_4.9.x_tree \
+// RUN: --gcc-toolchain="" \
+// RUN:   | FileCheck --check-prefix=CHECK-GENTOO-4-9-X-X32 %s
+// CHECK-GENTOO-4-9-X-X32: "{{.*}}clang{{.*}}" "-cc1"
+// CHECK-GENTOO-4-9-X-X32: "-resource-dir" "[[RESOURCE_DIR:[^"]+]]"
+// CHECK-GENTOO-4-9-X-X32: "-isysroot" "[[SYSROOT:[^"]+]]"
+// CHECK-GENTOO-4-9-X-X32: "-internal-isystem" "[[SYSROOT]]/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.x/include/g++-v4.9.3"
+// CHECK-GENTOO-4-9-X-X32: "-internal-isystem" "[[SYSROOT]]/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.x/include/g++-v4.9.3/x86_64-pc-linux-gnu/x32"
+// CHECK-GENTOO-4-9-X-X32: "-internal-isystem" "[[SYSROOT]]/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.x/include/g++-v4.9.3/backward"
+// CHECK-GENTOO-4-9-X-X32: "-internal-isystem" "[[SYSROOT]]/usr/local/include"
+// CHECK-GENTOO-4-9-X-X32: "-internal-isystem" "[[RESOURCE_DIR]]{{/|}}include"
+// CHECK-GENTOO-4-9-X-X32: "-internal-externc-isystem" "[[SYSROOT]]/include"
+// CHECK-GENTOO-4-9-X-X32: "-internal-externc-isystem" "[[SYSROOT]]/usr/include"
+//
+// RUN: %clang -no-canonical-prefixes %s -### -fsyntax-only 2>&1 \
+// RUN: -target i386-unknown-linux-gnu -stdlib=libstdc++ \
+// RUN: --sysroot=%S/Inputs/gentoo_linux_gcc_4.9.x_tree \
+// RUN: --gcc-toolchain="" \
+// RUN:   | FileCheck --check-prefix=CHECK-GENTOO-4-9-X-32 %s
+// CHECK-GENTOO-4-9-X-32: "{{.*}}clang{{.*}}" "-cc1"
+// CHECK-GENTOO-4-9-X-32: "-resource-dir" "[[RESOURCE_DIR:[^"]+]]"
+//

r329324 - Remove the temporary availability checking workaround for

2018-04-05 Thread Alex Lorenz via cfe-commits
Author: arphaman
Date: Thu Apr  5 11:12:06 2018
New Revision: 329324

URL: http://llvm.org/viewvc/llvm-project?rev=329324&view=rev
Log:
Remove the temporary availability checking workaround for
the nested declarations in @interface.

rdar://28825862

Modified:
cfe/trunk/lib/Sema/SemaDeclAttr.cpp
cfe/trunk/test/SemaObjC/class-unavail-warning.m

Modified: cfe/trunk/lib/Sema/SemaDeclAttr.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclAttr.cpp?rev=329324&r1=329323&r2=329324&view=diff
==
--- cfe/trunk/lib/Sema/SemaDeclAttr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclAttr.cpp Thu Apr  5 11:12:06 2018
@@ -6828,28 +6828,6 @@ static bool ShouldDiagnoseAvailabilityIn
 return false;
   };
 
-  // FIXME: This is a temporary workaround! Some existing Apple headers depends
-  // on nested declarations in an @interface having the availability of the
-  // interface when they really shouldn't: they are members of the enclosing
-  // context, and can referenced from there.
-  if (S.OriginalLexicalContext && cast(S.OriginalLexicalContext) != Ctx) 
{
-const auto *OrigCtx = cast(S.OriginalLexicalContext);
-if (CheckContext(OrigCtx))
-  return false;
-
-// An implementation implicitly has the availability of the interface.
-if (const auto *CatOrImpl = dyn_cast(OrigCtx)) {
-  if (const ObjCInterfaceDecl *Interface = CatOrImpl->getClassInterface())
-if (CheckContext(Interface))
-  return false;
-}
-// A category implicitly has the availability of the interface.
-else if (const auto *CatD = dyn_cast(OrigCtx))
-  if (const ObjCInterfaceDecl *Interface = CatD->getClassInterface())
-if (CheckContext(Interface))
-  return false;
-  }
-
   do {
 if (CheckContext(Ctx))
   return false;

Modified: cfe/trunk/test/SemaObjC/class-unavail-warning.m
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjC/class-unavail-warning.m?rev=329324&r1=329323&r2=329324&view=diff
==
--- cfe/trunk/test/SemaObjC/class-unavail-warning.m (original)
+++ cfe/trunk/test/SemaObjC/class-unavail-warning.m Thu Apr  5 11:12:06 2018
@@ -115,9 +115,9 @@ UNAVAILABLE __attribute__((objc_root_cla
 }
 @end
 
-typedef int unavailable_int UNAVAILABLE;
+typedef int unavailable_int UNAVAILABLE; // expected-note {{'unavailable_int' 
has been explicitly marked unavailable here}}
 
 UNAVAILABLE
 @interface A
-extern unavailable_int global_unavailable; // FIXME: this should be an error!
+extern unavailable_int global_unavailable; // expected-error 
{{'unavailable_int' is unavailable: not available}}
 @end


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


[PATCH] D45305: ObjCGNU: Fix empty v3 protocols being emitted two fields short

2018-04-05 Thread John McCall via Phabricator via cfe-commits
rjmccall added a comment.

The change LGTM, but please add a test.


Repository:
  rC Clang

https://reviews.llvm.org/D45305



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


[PATCH] D45277: [CUDA] Add amdgpu sub archs

2018-04-05 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl added inline comments.



Comment at: lib/Basic/Targets.cpp:161
+case CudaArch::GFX902:
+  return "320";
+case CudaArch::UNKNOWN:

tra wrote:
> Unless you're planning to guarantee 1:1 match to functionality provided by 
> nvidia's sm_32, it would be prudent to use some other value for the macro so 
> the source code has a way to tell these GPUs apart.
> 
> Another issue with this approach is that typical use pattern for 
> __CUDA_ARCH__ is 
> `#if __CUDA_ARCH__ >= XXX`. I don't expect that we'll always be able to 
> maintain order across GPU architectures among NVIDIA and AMD GPUs. Perhaps 
> for HIP compilation it would make more sense to define __CUDA_ARCH__ as 1 
> (this should serve as a legacy indication of device-side compilation) and 
> define __HIP_ARCH__ to indicate which AMD GPU we're compiling for without 
> accidentally enabling something that was intended for NVIDIA's GPUs only.
I think let `__CUDA_ARCH__`==1 for amdgcn is reasonable and I can make that 
change.

On the other hand, I think it may be difficult to define `__HIP_ARCH__` which 
can sort mixed nvptx/amdgcn GPU's by capability. I do think a well defined 
`__HIP_ARCH__` would be useful for users. Just need some further discussion how 
to define it.

For now, if there are specific codes for nvptx, it can continue use 
`__CUDA_ARCH__`. If there are specific codes for amdgcn, it can check 
predefined amdgpu canonical names, e.g. `__gfx803__`, etc. 


Repository:
  rC Clang

https://reviews.llvm.org/D45277



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


[PATCH] D45277: [CUDA] Add amdgpu sub archs

2018-04-05 Thread Artem Belevich via Phabricator via cfe-commits
tra added inline comments.



Comment at: lib/Basic/Targets.cpp:161
+case CudaArch::GFX902:
+  return "320";
+case CudaArch::UNKNOWN:

yaxunl wrote:
> tra wrote:
> > Unless you're planning to guarantee 1:1 match to functionality provided by 
> > nvidia's sm_32, it would be prudent to use some other value for the macro 
> > so the source code has a way to tell these GPUs apart.
> > 
> > Another issue with this approach is that typical use pattern for 
> > __CUDA_ARCH__ is 
> > `#if __CUDA_ARCH__ >= XXX`. I don't expect that we'll always be able to 
> > maintain order across GPU architectures among NVIDIA and AMD GPUs. Perhaps 
> > for HIP compilation it would make more sense to define __CUDA_ARCH__ as 1 
> > (this should serve as a legacy indication of device-side compilation) and 
> > define __HIP_ARCH__ to indicate which AMD GPU we're compiling for without 
> > accidentally enabling something that was intended for NVIDIA's GPUs only.
> I think let `__CUDA_ARCH__`==1 for amdgcn is reasonable and I can make that 
> change.
> 
> On the other hand, I think it may be difficult to define `__HIP_ARCH__` which 
> can sort mixed nvptx/amdgcn GPU's by capability. I do think a well defined 
> `__HIP_ARCH__` would be useful for users. Just need some further discussion 
> how to define it.
> 
> For now, if there are specific codes for nvptx, it can continue use 
> `__CUDA_ARCH__`. If there are specific codes for amdgcn, it can check 
> predefined amdgpu canonical names, e.g. `__gfx803__`, etc. 
OK.



Repository:
  rC Clang

https://reviews.llvm.org/D45277



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


[PATCH] D41148: [libcxx] implement declarations based on P0214R7.

2018-04-05 Thread Tim Shen via Phabricator via cfe-commits
timshen updated this revision to Diff 141188.
timshen added a comment.

Addressed comments.


https://reviews.llvm.org/D41148

Files:
  libcxx/include/experimental/__config
  libcxx/include/experimental/simd
  libcxx/include/module.modulemap
  libcxx/test/libcxx/double_include.sh.cpp
  libcxx/test/std/experimental/simd/nothing_to_do.pass.cpp
  libcxx/test/std/experimental/simd/simd.casts/simd_cast.pass.cpp
  libcxx/test/std/experimental/simd/simd.casts/static_simd_cast.pass.cpp
  libcxx/test/std/experimental/simd/simd.cons/broadcast.pass.cpp
  libcxx/test/std/experimental/simd/simd.cons/genertor.pass.cpp
  libcxx/test/std/experimental/simd/simd.traits/abi_for_size.pass.cpp
  libcxx/test/std/experimental/simd/simd.traits/is_abi_tag.pass.cpp
  libcxx/test/std/experimental/simd/simd.traits/is_simd.pass.cpp
  libcxx/test/std/experimental/simd/simd.traits/is_simd_flag_type.pass.cpp
  libcxx/test/std/experimental/simd/simd.traits/is_simd_mask.pass.cpp

Index: libcxx/test/std/experimental/simd/simd.traits/is_simd_mask.pass.cpp
===
--- /dev/null
+++ libcxx/test/std/experimental/simd/simd.traits/is_simd_mask.pass.cpp
@@ -0,0 +1,133 @@
+//===--===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===--===//
+
+// UNSUPPORTED: c++98, c++03
+
+// 
+//
+// [simd.traits]
+// template  struct is_simd_mask;
+// template  inline constexpr bool is_simd_mask_v = is_simd_mask::value;
+
+#include 
+#include 
+#include "test_macros.h"
+
+using namespace std::experimental::parallelism_v2;
+
+struct UserType {};
+
+static_assert(is_simd_mask>::value, "");
+static_assert(is_simd_mask>::value, "");
+static_assert(is_simd_mask>::value, "");
+static_assert(is_simd_mask>::value, "");
+static_assert(is_simd_mask>::value, "");
+static_assert(is_simd_mask>::value, "");
+static_assert(is_simd_mask>::value, "");
+static_assert(is_simd_mask>::value, "");
+static_assert(is_simd_mask>::value, "");
+static_assert(is_simd_mask>::value, "");
+
+static_assert(is_simd_mask>::value, "");
+static_assert(is_simd_mask>::value, "");
+static_assert(is_simd_mask>::value, "");
+static_assert(is_simd_mask>::value, "");
+static_assert(is_simd_mask>::value, "");
+static_assert(is_simd_mask>::value, "");
+static_assert(is_simd_mask>::value, "");
+static_assert(is_simd_mask>::value, "");
+static_assert(is_simd_mask>::value, "");
+static_assert(is_simd_mask>::value, "");
+
+static_assert(is_simd_mask>::value, "");
+static_assert(is_simd_mask>::value, "");
+static_assert(is_simd_mask>::value, "");
+static_assert(is_simd_mask>::value, "");
+static_assert(is_simd_mask>::value, "");
+static_assert(is_simd_mask>::value, "");
+static_assert(is_simd_mask>::value, "");
+static_assert(is_simd_mask>::value, "");
+static_assert(is_simd_mask>::value, "");
+static_assert(is_simd_mask>::value, "");
+
+static_assert(is_simd_mask>::value, "");
+static_assert(is_simd_mask>::value, "");
+static_assert(is_simd_mask>::value, "");
+static_assert(is_simd_mask>::value, "");
+static_assert(is_simd_mask>::value, "");
+static_assert(is_simd_mask>::value, "");
+static_assert(is_simd_mask>::value, "");
+static_assert(is_simd_mask>::value, "");
+static_assert(is_simd_mask>::value, "");
+static_assert(is_simd_mask>::value, "");
+
+static_assert(!is_simd_mask::value, "");
+static_assert(!is_simd_mask::value, "");
+static_assert(!is_simd_mask::value, "");
+static_assert(!is_simd_mask>::value, "");
+static_assert(!is_simd_mask>::value, "");
+static_assert(!is_simd_mask::value, "");
+
+#if TEST_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) &&\
+!defined(_LIBCPP_HAS_NO_INLINE_VARIABLES)
+
+static_assert(is_simd_mask_v>, "");
+static_assert(is_simd_mask_v>, "");
+static_assert(is_simd_mask_v>, "");
+static_assert(is_simd_mask_v>, "");
+static_assert(is_simd_mask_v>, "");
+static_assert(is_simd_mask_v>, "");
+static_assert(is_simd_mask_v>, "");
+static_assert(is_simd_mask_v>, "");
+static_assert(is_simd_mask_v>, "");
+static_assert(is_simd_mask_v>, "");
+
+static_assert(is_simd_mask_v>, "");
+static_assert(is_simd_mask_v>, "");
+static_assert(is_simd_mask_v>, "");
+static_assert(is_simd_mask_v>, "");
+static_assert(is_simd_mask_v>, "");
+static_assert(is_simd_mask_v>, "");
+static_assert(is_simd_mask_v>, "");
+static_assert(is_simd_mask_v>, "");
+static_assert(is_simd_mask_v>, "");
+static_assert(is_simd_mask_v>, "");
+
+static_assert(is_simd_mask_v>, "");
+static_assert(is_simd_mask_v>, "");
+static_assert(is_simd_mask_v>, "");
+static_assert(is_simd_mask_v>, "");
+static_assert(is_simd_mask_v>, "");
+static_assert(is_simd_mask_v>, "");
+static_assert(is_simd_mask_v>, "");
+static_assert(is_simd_mask_v>, "");
+static_asser

[PATCH] D41148: [libcxx] implement declarations based on P0214R7.

2018-04-05 Thread Tim Shen via Phabricator via cfe-commits
timshen marked 5 inline comments as done.
timshen added inline comments.



Comment at: 
libcxx/test/std/experimental/simd/simd.traits/is_simd_mask.pass.cpp:68
+
+static_assert(!is_simd_mask::value, "");
+

mclow.lists wrote:
> How about a couple more negative tests here?
> You've got `int`, how about `float`, and `std::string` and a few of the simd 
> types?
> 
I used "UserType" instead of std::string, as I don't want to pull in the whole 
 header. I figured that UserType should serve the same purpose.


https://reviews.llvm.org/D41148



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


[PATCH] D44659: [libcxx] Optimize -O0 performance for operators

2018-04-05 Thread Tim Shen via Phabricator via cfe-commits
timshen updated this revision to Diff 141189.
timshen added a comment.

Also optimize -O0 load and stores by using memcpy.


https://reviews.llvm.org/D44659

Files:
  libcxx/include/experimental/simd
  libcxx/test/std/experimental/simd/simd.elementwise/operators.pass.cpp

Index: libcxx/test/std/experimental/simd/simd.elementwise/operators.pass.cpp
===
--- libcxx/test/std/experimental/simd/simd.elementwise/operators.pass.cpp
+++ libcxx/test/std/experimental/simd/simd.elementwise/operators.pass.cpp
@@ -64,136 +64,138 @@
 
 using namespace std::experimental::parallelism_v2;
 
+template 
 void test_pure_operators() {
   {
-native_simd a(42), b(4);
+SimdType a(42), b(4);
 
-assert(all_of(~a == native_simd(~42)));
+assert(all_of(~a == SimdType(~42)));
 assert(all_of(+a == a));
-assert(all_of(-a == native_simd(-42)));
-assert(all_of(a + b == native_simd(42 + 4)));
-assert(all_of(a - b == native_simd(42 - 4)));
-assert(all_of(a * b == native_simd(42 * 4)));
-assert(all_of(a / b == native_simd(42 / 4)));
-assert(all_of(a % b == native_simd(42 % 4)));
-assert(all_of((a & b) == native_simd(42 & 4)));
-assert(all_of((a | b) == native_simd(42 | 4)));
-assert(all_of((a ^ b) == native_simd(42 ^ 4)));
-assert(all_of((a << b) == native_simd(42 << 4)));
-assert(all_of((a >> b) == native_simd(42 >> 4)));
-assert(all_of((a << 4) == native_simd(42 << 4)));
-assert(all_of((a >> 4) == native_simd(42 >> 4)));
+assert(all_of(-a == SimdType(-42)));
+assert(all_of(a + b == SimdType(42 + 4)));
+assert(all_of(a - b == SimdType(42 - 4)));
+assert(all_of(a * b == SimdType(42 * 4)));
+assert(all_of(a / b == SimdType(42 / 4)));
+assert(all_of(a % b == SimdType(42 % 4)));
+assert(all_of((a & b) == SimdType(42 & 4)));
+assert(all_of((a | b) == SimdType(42 | 4)));
+assert(all_of((a ^ b) == SimdType(42 ^ 4)));
+assert(all_of((a << b) == SimdType(42 << 4)));
+assert(all_of((a >> b) == SimdType(42 >> 4)));
+assert(all_of((a << 4) == SimdType(42 << 4)));
+assert(all_of((a >> 4) == SimdType(42 >> 4)));
   }
   {
-native_simd a([](int i) { return 2 * i + 1; }),
-b([](int i) { return i + 1; });
+SimdType a([](int i) { return 2 * i + 1; }), b([](int i) { return i + 1; });
 
-assert(all_of(~a == native_simd([](int i) { return ~(2 * i + 1); })));
+assert(all_of(~a == SimdType([](int i) { return ~(2 * i + 1); })));
 assert(all_of(+a == a));
-assert(all_of(-a == native_simd([](int i) { return -(2 * i + 1); })));
-assert(all_of(a + b == native_simd([](int i) { return 3 * i + 2; })));
-assert(all_of(a - b == native_simd([](int i) { return i; })));
-assert(all_of(a * b == native_simd(
-   [](int i) { return (2 * i + 1) * (i + 1); })));
-assert(all_of(a / b == native_simd(
-   [](int i) { return (2 * i + 1) / (i + 1); })));
-assert(all_of(a % b == native_simd(
-   [](int i) { return (2 * i + 1) % (i + 1); })));
-assert(all_of((a & b) == native_simd(
- [](int i) { return (2 * i + 1) & (i + 1); })));
-assert(all_of((a | b) == native_simd(
- [](int i) { return (2 * i + 1) | (i + 1); })));
-assert(all_of((a ^ b) == native_simd(
- [](int i) { return (2 * i + 1) ^ (i + 1); })));
+assert(all_of(-a == SimdType([](int i) { return -(2 * i + 1); })));
+assert(all_of(a + b == SimdType([](int i) { return 3 * i + 2; })));
+assert(all_of(a - b == SimdType([](int i) { return i; })));
+assert(
+all_of(a * b == SimdType([](int i) { return (2 * i + 1) * (i + 1); })));
+assert(
+all_of(a / b == SimdType([](int i) { return (2 * i + 1) / (i + 1); })));
+assert(
+all_of(a % b == SimdType([](int i) { return (2 * i + 1) % (i + 1); })));
+assert(all_of((a & b) ==
+  SimdType([](int i) { return (2 * i + 1) & (i + 1); })));
+assert(all_of((a | b) ==
+  SimdType([](int i) { return (2 * i + 1) | (i + 1); })));
+assert(all_of((a ^ b) ==
+  SimdType([](int i) { return (2 * i + 1) ^ (i + 1); })));
   }
 }
 
+template 
 void test_mutating_opreators() {
-  native_simd b(4);
+  SimdType b(4);
   {
-native_simd a(42);
-assert(all_of(++a == native_simd(43)));
-assert(all_of(a == native_simd(43)));
+SimdType a(42);
+assert(all_of(++a == SimdType(43)));
+assert(all_of(a == SimdType(43)));
   }
   {
-native_simd a(42);
-assert(all_of(a++ == native_simd(42)));
-assert(all_of(a == native_simd(43)));
+SimdType a(42);
+assert(all_of(a++ == SimdType(42)));
+assert(all_of(a == SimdType(43)));
   }
   {
-native_simd a(42);
-assert(all_of(--a == native_simd(41)));
-assert(all_of(a == native_simd(41)));
+SimdType 

[PATCH] D42092: implement C++ dr388 for the Itanium C++ ABI: proper handling of catching exceptions by reference

2018-04-05 Thread John McCall via Phabricator via cfe-commits
rjmccall added a comment.

In https://reviews.llvm.org/D42092#1057881, @rsmith wrote:

> In https://reviews.llvm.org/D42092#983892, @rjmccall wrote:
>
> > This is definitely something that the personality function should handle.  
> > If we want to do heroic things in the absence of personality function 
> > support, we can, but the code should at least be written to be conditional 
> > on personality support.
>
>
> I suppose the question is, do we want to do such heroic things?
>
> Also, we don't have a personality function that can get this right, nor even 
> a concrete design proposed for one. It doesn't seem too hard -- we'd need to 
> extend the EH table to indicate catch-by-reference -- but there's nothing for 
> this to be made conditional on right now. I can easily add a CodeGenOption 
> that turns this all off, if you'd like.


Well, I don't have a use case for an option like that.  If we're going to add 
the code to support this even without a cooperative personality, I think we can 
enable it unconditionally for now.

Issue #3 is tricky; it's arguably not okay to force a landing at a landing pad 
if we're not actually catching anything.

For what it's worth, I don't think the Itanium ABI needs any changes here.  The 
existence of any particular personality function, and that function's 
expectations about the LSDA, are not official ABI.   __gxx_personality_v0 is a 
sort of private ABI, a standard solution offered by libsupc++ / libc++abi for 
the convenience of compilers, but we could totally just write a new personality 
and add it to compiler-rt (or libc++abi, enabled by deployment-target-specific 
checks) if that was the best solution.

>> If we can rev the personality function, we should also fix the longstanding 
>> problem with references to pointers to classes.
> 
> Which issue is that? (And does this patch fail to address it? It should 
> prevent catching `Derived*` by (non-const) `Base *&` while still allowing 
> catch by `Base *const&`, if that's the issue you're referring to.)

Yes, that's the issue I'm referring to, and yeah, I see that you're addressing 
it here.


Repository:
  rC Clang

https://reviews.llvm.org/D42092



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


r329332 - DR1672, DR1813, DR1881, DR2120: Implement recent fixes to "standard

2018-04-05 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Thu Apr  5 11:55:37 2018
New Revision: 329332

URL: http://llvm.org/viewvc/llvm-project?rev=329332&view=rev
Log:
DR1672, DR1813, DR1881, DR2120: Implement recent fixes to "standard
layout" rules.

The new rules say that a standard-layout struct has its first non-static
data member and all base classes at offset 0, and consider a class to
not be standard-layout if that would result in multiple subobjects of a
single type having the same address.

We track "is C++11 standard-layout class" separately from "is
standard-layout class" so that the ABIs that need this information can
still use it.

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

Added:
cfe/trunk/test/Layout/watchos-standard-layout.cpp
Modified:
cfe/trunk/docs/ReleaseNotes.rst
cfe/trunk/include/clang/AST/DeclCXX.h
cfe/trunk/include/clang/AST/Type.h
cfe/trunk/lib/AST/ASTImporter.cpp
cfe/trunk/lib/AST/DeclCXX.cpp
cfe/trunk/lib/AST/RecordLayoutBuilder.cpp
cfe/trunk/lib/Serialization/ASTReaderDecl.cpp
cfe/trunk/lib/Serialization/ASTWriter.cpp
cfe/trunk/test/CXX/drs/dr14xx.cpp
cfe/trunk/test/CXX/drs/dr16xx.cpp
cfe/trunk/test/CXX/drs/dr18xx.cpp
cfe/trunk/test/CXX/drs/dr21xx.cpp
cfe/trunk/test/CXX/drs/dr22xx.cpp
cfe/trunk/test/SemaCXX/type-traits.cpp
cfe/trunk/www/cxx_dr_status.html
cfe/trunk/www/make_cxx_dr_status

Modified: cfe/trunk/docs/ReleaseNotes.rst
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/ReleaseNotes.rst?rev=329332&r1=329331&r2=329332&view=diff
==
--- cfe/trunk/docs/ReleaseNotes.rst (original)
+++ cfe/trunk/docs/ReleaseNotes.rst Thu Apr  5 11:55:37 2018
@@ -66,6 +66,11 @@ Non-comprehensive list of changes in thi
   For example, the ``clang`` binary will be called ``clang-7``
   instead of ``clang-7.0``.
 
+- Clang implements a collection of recent fixes to the C++ standard's 
definition
+  of "standard-layout". In particular, a class is only considered to be
+  standard-layout if all base classes and the first data member (or bit-field)
+  can be laid out at offset zero.
+
 - ...
 
 New Compiler Flags

Modified: cfe/trunk/include/clang/AST/DeclCXX.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/DeclCXX.h?rev=329332&r1=329331&r2=329332&view=diff
==
--- cfe/trunk/include/clang/AST/DeclCXX.h (original)
+++ cfe/trunk/include/clang/AST/DeclCXX.h Thu Apr  5 11:55:37 2018
@@ -348,7 +348,12 @@ class CXXRecordDecl : public RecordDecl
 /// one pure virtual function, (that can come from a base class).
 unsigned Abstract : 1;
 
-/// \brief True when this class has standard layout.
+/// \brief True when this class is standard-layout, per the applicable
+/// language rules (including DRs).
+unsigned IsStandardLayout : 1;
+
+/// \brief True when this class was standard-layout under the C++11
+/// definition.
 ///
 /// C++11 [class]p7.  A standard-layout class is a class that:
 /// * has no non-static data members of type non-standard-layout class (or
@@ -362,13 +367,19 @@ class CXXRecordDecl : public RecordDecl
 ///   classes with non-static data members, and
 /// * has no base classes of the same type as the first non-static data
 ///   member.
-unsigned IsStandardLayout : 1;
+unsigned IsCXX11StandardLayout : 1;
 
-/// \brief True when there are no non-empty base classes.
-///
+/// \brief True when any base class has any declared non-static data
+/// members or bit-fields.
 /// This is a helper bit of state used to implement IsStandardLayout more
 /// efficiently.
-unsigned HasNoNonEmptyBases : 1;
+unsigned HasBasesWithFields : 1;
+
+/// \brief True when any base class has any declared non-static data
+/// members.
+/// This is a helper bit of state used to implement IsCXX11StandardLayout
+/// more efficiently.
+unsigned HasBasesWithNonStaticDataMembers : 1;
 
 /// \brief True when there are private non-static data members.
 unsigned HasPrivateFields : 1;
@@ -696,6 +707,12 @@ class CXXRecordDecl : public RecordDecl
   /// deserializing the friends from an external AST source.
   FriendDecl *getFirstFriend() const;
 
+  /// Determine whether this class has an empty base class subobject of type X
+  /// or of one of the types that might be at offset 0 within X (per the C++
+  /// "standard layout" rules).
+  bool hasSubobjectAtOffsetZeroOfEmptyBaseType(ASTContext &Ctx,
+   const CXXRecordDecl *X);
+
 protected:
   CXXRecordDecl(Kind K, TagKind TK, const ASTContext &C, DeclContext *DC,
 SourceLocation StartLoc, SourceLocation IdLoc,
@@ -1301,10 +1318,14 @@ public:
   /// not overridden.
   bool isAbstract() const { return data().Abstract; }
 
-  /// \brief Determine whether this class has standard 

[PATCH] D45176: implement recent "standard-layout" changes

2018-04-05 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC329332: DR1672, DR1813, DR1881, DR2120: Implement recent 
fixes to "standard (authored by rsmith, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D45176?vs=140897&id=141193#toc

Repository:
  rC Clang

https://reviews.llvm.org/D45176

Files:
  docs/ReleaseNotes.rst
  include/clang/AST/DeclCXX.h
  include/clang/AST/Type.h
  lib/AST/ASTImporter.cpp
  lib/AST/DeclCXX.cpp
  lib/AST/RecordLayoutBuilder.cpp
  lib/Serialization/ASTReaderDecl.cpp
  lib/Serialization/ASTWriter.cpp
  test/CXX/drs/dr14xx.cpp
  test/CXX/drs/dr16xx.cpp
  test/CXX/drs/dr18xx.cpp
  test/CXX/drs/dr21xx.cpp
  test/CXX/drs/dr22xx.cpp
  test/Layout/watchos-standard-layout.cpp
  test/SemaCXX/type-traits.cpp
  www/cxx_dr_status.html
  www/make_cxx_dr_status

Index: lib/Serialization/ASTReaderDecl.cpp
===
--- lib/Serialization/ASTReaderDecl.cpp
+++ lib/Serialization/ASTReaderDecl.cpp
@@ -1563,7 +1563,9 @@
   Data.Polymorphic = Record.readInt();
   Data.Abstract = Record.readInt();
   Data.IsStandardLayout = Record.readInt();
-  Data.HasNoNonEmptyBases = Record.readInt();
+  Data.IsCXX11StandardLayout = Record.readInt();
+  Data.HasBasesWithFields = Record.readInt();
+  Data.HasBasesWithNonStaticDataMembers = Record.readInt();
   Data.HasPrivateFields = Record.readInt();
   Data.HasProtectedFields = Record.readInt();
   Data.HasPublicFields = Record.readInt();
@@ -1702,7 +1704,9 @@
   MATCH_FIELD(Polymorphic)
   MATCH_FIELD(Abstract)
   MATCH_FIELD(IsStandardLayout)
-  MATCH_FIELD(HasNoNonEmptyBases)
+  MATCH_FIELD(IsCXX11StandardLayout)
+  MATCH_FIELD(HasBasesWithFields)
+  MATCH_FIELD(HasBasesWithNonStaticDataMembers)
   MATCH_FIELD(HasPrivateFields)
   MATCH_FIELD(HasProtectedFields)
   MATCH_FIELD(HasPublicFields)
Index: lib/Serialization/ASTWriter.cpp
===
--- lib/Serialization/ASTWriter.cpp
+++ lib/Serialization/ASTWriter.cpp
@@ -5995,7 +5995,9 @@
   Record->push_back(Data.Polymorphic);
   Record->push_back(Data.Abstract);
   Record->push_back(Data.IsStandardLayout);
-  Record->push_back(Data.HasNoNonEmptyBases);
+  Record->push_back(Data.IsCXX11StandardLayout);
+  Record->push_back(Data.HasBasesWithFields);
+  Record->push_back(Data.HasBasesWithNonStaticDataMembers);
   Record->push_back(Data.HasPrivateFields);
   Record->push_back(Data.HasProtectedFields);
   Record->push_back(Data.HasPublicFields);
Index: lib/AST/RecordLayoutBuilder.cpp
===
--- lib/AST/RecordLayoutBuilder.cpp
+++ lib/AST/RecordLayoutBuilder.cpp
@@ -2134,7 +2134,7 @@
 // mode; fortunately, that is true because we want to assign
 // consistently semantics to the type-traits intrinsics (or at
 // least as many of them as possible).
-return RD->isTrivial() && RD->isStandardLayout();
+return RD->isTrivial() && RD->isCXX11StandardLayout();
   }
 
   llvm_unreachable("bad tail-padding use kind");
Index: lib/AST/ASTImporter.cpp
===
--- lib/AST/ASTImporter.cpp
+++ lib/AST/ASTImporter.cpp
@@ -1071,7 +1071,10 @@
 ToData.Polymorphic = FromData.Polymorphic;
 ToData.Abstract = FromData.Abstract;
 ToData.IsStandardLayout = FromData.IsStandardLayout;
-ToData.HasNoNonEmptyBases = FromData.HasNoNonEmptyBases;
+ToData.IsCXX11StandardLayout = FromData.IsCXX11StandardLayout;
+ToData.HasBasesWithFields = FromData.HasBasesWithFields;
+ToData.HasBasesWithNonStaticDataMembers =
+FromData.HasBasesWithNonStaticDataMembers;
 ToData.HasPrivateFields = FromData.HasPrivateFields;
 ToData.HasProtectedFields = FromData.HasProtectedFields;
 ToData.HasPublicFields = FromData.HasPublicFields;
Index: lib/AST/DeclCXX.cpp
===
--- lib/AST/DeclCXX.cpp
+++ lib/AST/DeclCXX.cpp
@@ -74,7 +74,8 @@
 CXXRecordDecl::DefinitionData::DefinitionData(CXXRecordDecl *D)
 : UserDeclaredConstructor(false), UserDeclaredSpecialMembers(0),
   Aggregate(true), PlainOldData(true), Empty(true), Polymorphic(false),
-  Abstract(false), IsStandardLayout(true), HasNoNonEmptyBases(true),
+  Abstract(false), IsStandardLayout(true), IsCXX11StandardLayout(true),
+  HasBasesWithFields(false), HasBasesWithNonStaticDataMembers(false),
   HasPrivateFields(false), HasProtectedFields(false),
   HasPublicFields(false), HasMutableFields(false), HasVariantMembers(false),
   HasOnlyCMembers(true), HasInClassInitializer(false),
@@ -161,6 +162,25 @@
   return R;
 }
 
+/// Determine whether a class has a repeated base class. This is intended for
+/// use when determining if a class is standard-layout, so makes no attempt to
+/// handle virtual bases.
+static bool hasRepeatedBaseClass(const CXXRecordDecl *StartRD) {
+  llvm::Small

[PATCH] D45096: Allow the creation of human-friendly ASTDumper to arbitrary output stream

2018-04-05 Thread Whisperity via Phabricator via cfe-commits
whisperity updated this revision to Diff 141194.
whisperity added a comment.

- Overload removed, now only one `CreateASTDumper` function remains.
- Updated the call sites of this function to use this call.


Repository:
  rC Clang

https://reviews.llvm.org/D45096

Files:
  docs/HowToSetupToolingForLLVM.rst
  include/clang/Frontend/ASTConsumers.h
  lib/Frontend/ASTConsumers.cpp
  lib/Frontend/FrontendActions.cpp
  tools/clang-check/ClangCheck.cpp
  tools/clang-import-test/clang-import-test.cpp


Index: tools/clang-import-test/clang-import-test.cpp
===
--- tools/clang-import-test/clang-import-test.cpp
+++ tools/clang-import-test/clang-import-test.cpp
@@ -313,7 +313,7 @@
   auto &CG = *static_cast(ASTConsumers.back().get());
 
   if (ShouldDumpAST)
-ASTConsumers.push_back(CreateASTDumper("", true, false, false));
+ASTConsumers.push_back(CreateASTDumper(nullptr, "", true, false, false));
 
   CI.getDiagnosticClient().BeginSourceFile(
   CI.getCompilerInstance().getLangOpts(),
Index: tools/clang-check/ClangCheck.cpp
===
--- tools/clang-check/ClangCheck.cpp
+++ tools/clang-check/ClangCheck.cpp
@@ -138,7 +138,8 @@
 if (ASTList)
   return clang::CreateASTDeclNodeLister();
 if (ASTDump)
-  return clang::CreateASTDumper(ASTDumpFilter, /*DumpDecls=*/true,
+  return clang::CreateASTDumper(nullptr, ASTDumpFilter,
+/*DumpDecls=*/true,
 /*Deserialize=*/false,
 /*DumpLookups=*/false);
 if (ASTPrint)
Index: lib/Frontend/FrontendActions.cpp
===
--- lib/Frontend/FrontendActions.cpp
+++ lib/Frontend/FrontendActions.cpp
@@ -74,7 +74,8 @@
 
 std::unique_ptr
 ASTDumpAction::CreateASTConsumer(CompilerInstance &CI, StringRef InFile) {
-  return CreateASTDumper(CI.getFrontendOpts().ASTDumpFilter,
+  return CreateASTDumper(nullptr,
+ CI.getFrontendOpts().ASTDumpFilter,
  CI.getFrontendOpts().ASTDumpDecls,
  CI.getFrontendOpts().ASTDumpAll,
  CI.getFrontendOpts().ASTDumpLookups);
Index: lib/Frontend/ASTConsumers.cpp
===
--- lib/Frontend/ASTConsumers.cpp
+++ lib/Frontend/ASTConsumers.cpp
@@ -138,12 +138,14 @@
FilterString);
 }
 
-std::unique_ptr clang::CreateASTDumper(StringRef FilterString,
-bool DumpDecls,
-bool Deserialize,
-bool DumpLookups) {
+std::unique_ptr
+clang::CreateASTDumper(std::unique_ptr Out,
+   StringRef FilterString,
+   bool DumpDecls,
+   bool Deserialize,
+   bool DumpLookups) {
   assert((DumpDecls || Deserialize || DumpLookups) && "nothing to dump");
-  return llvm::make_unique(nullptr,
+  return llvm::make_unique(std::move(Out),
Deserialize ? ASTPrinter::DumpFull :
DumpDecls ? ASTPrinter::Dump :
ASTPrinter::None,
Index: include/clang/Frontend/ASTConsumers.h
===
--- include/clang/Frontend/ASTConsumers.h
+++ include/clang/Frontend/ASTConsumers.h
@@ -34,9 +34,10 @@
 std::unique_ptr CreateASTPrinter(std::unique_ptr OS,
   StringRef FilterString);
 
-// AST dumper: dumps the raw AST in human-readable form to stderr; this is
-// intended for debugging.
-std::unique_ptr CreateASTDumper(StringRef FilterString,
+// AST dumper: dumps the raw AST in human-readable form to the given output
+// stream.
+std::unique_ptr CreateASTDumper(std::unique_ptr OS,
+ StringRef FilterString,
  bool DumpDecls, bool Deserialize,
  bool DumpLookups);
 
Index: docs/HowToSetupToolingForLLVM.rst
===
--- docs/HowToSetupToolingForLLVM.rst
+++ docs/HowToSetupToolingForLLVM.rst
@@ -133,7 +133,7 @@
   if (this->ASTList.operator _Bool())
   return clang::CreateASTDeclNodeLister();
   if (this->ASTDump.operator _Bool())
-  return clang::CreateASTDumper(this->ASTDumpFilter);
+  return clang::CreateASTDumper(nullptr, this->ASTDumpFilter);
   if (this->ASTPrint.operator _Bool())
   return clang::CreateASTPrinter(&llvm::outs(), this->ASTDumpFilter);
   return new clang::ASTConsumer();


Index: tools/clang-import-test/clang-import-

[PATCH] D45306: PR36992 don't overwrite virtual bases in tail padding

2018-04-05 Thread John McCall via Phabricator via cfe-commits
rjmccall added a comment.

Changing the requirements on the return-value slot would be an ABI break, no?  
And it would force to us to treat all complete-object constructions as 
nvsize-limited unless they're constructions of known sizeof-sized allocations.




Comment at: CodeGen/CGDecl.cpp:1462
+  AggValueSlot::IsNotAliased,
+  AggValueSlot::DoesNotOverlap));
 }

How is 'does not overlap' justified here?  Should this be propagated into the 
LValue?



Comment at: CodeGen/CGExprAgg.cpp:1721
+  TypeInfo = getContext().getTypeInfoInChars(BaseEltTy);
+  // FIXME: What about VLAs of VLAs?
   assert(!TypeInfo.first.isZero());

emitArrayLength drills down to the base non-array type; it handles nested VLAs.


Repository:
  rC Clang

https://reviews.llvm.org/D45306



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


[PATCH] D45310: Warn about memcpy'ing non-trivial C structs

2018-04-05 Thread John McCall via Phabricator via cfe-commits
rjmccall added inline comments.



Comment at: include/clang/AST/NonTrivialCStructTypeVisitor.h:12
+//
+//===--===//
+

The header comment here was clearly just copied from another file.

I would name this header "NonTrivialTypeVisitor.h"; I don't think the CStruct 
adds anything, especially because the visitors actually start from types.



Comment at: include/clang/AST/NonTrivialCStructTypeVisitor.h:30
+if (asDerived().getContext().getAsArrayType(FT))
+  return asDerived().visitArray(DK, FT, std::forward(Args)...);
+

Should you have this pass the array type down?  And is it really important to 
do this in the generic visitor?  It seems like something you could do in an 
IRGen subclass.



Comment at: include/clang/Basic/DiagnosticSemaKinds.td:619
+  "%select{primitive-default-initialize|primitive-copy}3">,
+  InGroup>;
+def note_nontrivial_field : Note<

I think this warning group should be -Wnontrivial-memaccess, and maybe 
-Wclass-memaccess should just be a subgroup of it.



Comment at: lib/Sema/SemaChecking.cpp:7343
+  SourceLocation SL) {
+const auto *AT = getContext().getAsConstantArrayType(FT);
+visit(PDIK, getContext().getBaseElementType(AT), SL);

It would be better to just getAsArrayType, for generality purposes.


Repository:
  rC Clang

https://reviews.llvm.org/D45310



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


Re: r328680 - [ObjC] Make C++ triviality type traits available to non-trivial C

2018-04-05 Thread John McCall via cfe-commits


> On Apr 4, 2018, at 7:37 PM, Akira Hatanaka  wrote:
> 
> 
> 
>> On Apr 4, 2018, at 4:24 PM, Akira Hatanaka via cfe-commits 
>> mailto:cfe-commits@lists.llvm.org>> wrote:
>> 
>>> 
>>> On Apr 4, 2018, at 3:38 PM, Richard Smith >> > wrote:
>>> 
>>> Hi Akira,
>>> 
>>> This change has broken the C++ versions of these type traits for classes 
>>> with volatile members. Such classes are required to claim to be trivial per 
>>> C++ DR 2094 
>>> (http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#2094 
>>> ) but 
>>> return false from isNonTrivialToPrimitiveCopy().
>>> 
>> 
>> Oh that’s right. The function returns false when 
>> isNonTrivialToPrimitiveCopy() returns PCK_VolatileTrivial. That is wrong.
>> 
>>> Also, exposing these __has_* traits more widely seems like a backwards step 
>>> to me: these traits are deprecated, near-useless, and we're trying to 
>>> remove them. No code should be using them under any circumstances; the 
>>> __is_* traits should be used instead.
>>> 
>> 
>> The __is_* traits (is_trivially_copy_constructible, etc.) are templates 
>> defined in libcxx, so it seems that we can’t use them when compiling in C 
>> mode. Is it OK to add their definitions to TokenKinds.def as non-C++ 
>> keywords?
>> 
> 
> Or perhaps redefine the six __has_* traits used here as non-C++ (KEYNOCXX or 
> ‘KEYC99 | KEYC11') keywords?

I think Richard is talking about e.g. the __is_trivially_destructible intrinsic 
type trait function rather than std::is_trivially_destructible.

Do we have a concrete need to expose these type traits to C?

John.

> 
>>> On 27 March 2018 at 17:12, Akira Hatanaka via cfe-commits 
>>> mailto:cfe-commits@lists.llvm.org>> wrote:
>>> Author: ahatanak
>>> Date: Tue Mar 27 17:12:08 2018
>>> New Revision: 328680
>>> 
>>> URL: http://llvm.org/viewvc/llvm-project?rev=328680&view=rev 
>>> 
>>> Log:
>>> [ObjC] Make C++ triviality type traits available to non-trivial C
>>> structs.
>>> 
>>> r326307 and r327870 made changes that allowed using non-trivial C
>>> structs with fields qualified with __strong or __weak. This commit makes
>>> the following C++ triviality type traits available to non-trivial C
>>> structs:
>>> 
>>> __has_trivial_assign
>>> __has_trivial_move_assign
>>> __has_trivial_copy
>>> __has_trivial_move_constructor
>>> __has_trivial_constructor
>>> __has_trivial_destructor
>>> 
>>> rdar://problem/33599681 
>>> 
>>> Differential Revision: https://reviews.llvm.org/D44913 
>>> 
>>> 
>>> Added:
>>> cfe/trunk/test/SemaObjC/non-trivial-struct-traits.m
>>> Modified:
>>> cfe/trunk/include/clang/Basic/TokenKinds.def
>>> cfe/trunk/lib/Sema/SemaExprCXX.cpp
>>> 
>>> Modified: cfe/trunk/include/clang/Basic/TokenKinds.def
>>> URL: 
>>> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/TokenKinds.def?rev=328680&r1=328679&r2=328680&view=diff
>>>  
>>> 
>>> ==
>>> --- cfe/trunk/include/clang/Basic/TokenKinds.def (original)
>>> +++ cfe/trunk/include/clang/Basic/TokenKinds.def Tue Mar 27 17:12:08 2018
>>> @@ -433,12 +433,12 @@ TYPE_TRAIT_1(__has_nothrow_assign, HasNo
>>>  TYPE_TRAIT_1(__has_nothrow_move_assign, HasNothrowMoveAssign, KEYCXX)
>>>  TYPE_TRAIT_1(__has_nothrow_copy, HasNothrowCopy, KEYCXX)
>>>  TYPE_TRAIT_1(__has_nothrow_constructor, HasNothrowConstructor, KEYCXX)
>>> -TYPE_TRAIT_1(__has_trivial_assign, HasTrivialAssign, KEYCXX)
>>> -TYPE_TRAIT_1(__has_trivial_move_assign, HasTrivialMoveAssign, KEYCXX)
>>> -TYPE_TRAIT_1(__has_trivial_copy, HasTrivialCopy, KEYCXX)
>>> -TYPE_TRAIT_1(__has_trivial_constructor, HasTrivialDefaultConstructor, 
>>> KEYCXX)
>>> -TYPE_TRAIT_1(__has_trivial_move_constructor, HasTrivialMoveConstructor, 
>>> KEYCXX)
>>> -TYPE_TRAIT_1(__has_trivial_destructor, HasTrivialDestructor, KEYCXX)
>>> +TYPE_TRAIT_1(__has_trivial_assign, HasTrivialAssign, KEYALL)
>>> +TYPE_TRAIT_1(__has_trivial_move_assign, HasTrivialMoveAssign, KEYALL)
>>> +TYPE_TRAIT_1(__has_trivial_copy, HasTrivialCopy, KEYALL)
>>> +TYPE_TRAIT_1(__has_trivial_constructor, HasTrivialDefaultConstructor, 
>>> KEYALL)
>>> +TYPE_TRAIT_1(__has_trivial_move_constructor, HasTrivialMoveConstructor, 
>>> KEYALL)
>>> +TYPE_TRAIT_1(__has_trivial_destructor, HasTrivialDestructor, KEYALL)
>>>  TYPE_TRAIT_1(__has_virtual_destructor, HasVirtualDestructor, KEYCXX)
>>>  TYPE_TRAIT_1(__is_abstract, IsAbstract, KEYCXX)
>>>  TYPE_TRAIT_1(__is_aggregate, IsAggregate, KEYCXX)
>>> 
>>> Modified: cfe/trunk/lib/Sema/SemaExprCXX.cpp
>>> URL: 
>>> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExprCXX.cpp?rev=328680&r1=328679&r2=328680&view=diff
>>>  
>>> 

[PATCH] D44295: [clang-tidy] Detects and fixes calls to grand-...parent virtual methods instead of calls to parent's virtual methods

2018-04-05 Thread Zinovy Nis via Phabricator via cfe-commits
zinovy.nis updated this revision to Diff 141199.
zinovy.nis added a comment.

- Switched to use 'tooling::fixit::getText' for qualified names.
- Shortened test code with {{.*}}.


https://reviews.llvm.org/D44295

Files:
  clang-tidy/bugprone/BugproneTidyModule.cpp
  clang-tidy/bugprone/CMakeLists.txt
  clang-tidy/bugprone/ParentVirtualCallCheck.cpp
  clang-tidy/bugprone/ParentVirtualCallCheck.h
  docs/ReleaseNotes.rst
  docs/clang-tidy/checks/bugprone-parent-virtual-call.rst
  docs/clang-tidy/checks/list.rst
  test/clang-tidy/bugprone-parent-virtual-call.cpp

Index: test/clang-tidy/bugprone-parent-virtual-call.cpp
===
--- /dev/null
+++ test/clang-tidy/bugprone-parent-virtual-call.cpp
@@ -0,0 +1,179 @@
+// RUN: %check_clang_tidy %s bugprone-parent-virtual-call %t
+
+extern int foo();
+
+class A {
+public:
+  A() = default;
+  virtual ~A() = default;
+
+  virtual int virt_1() { return foo() + 1; }
+  virtual int virt_2() { return foo() + 2; }
+
+  int non_virt() { return foo() + 3; }
+  static int stat() { return foo() + 4; }
+};
+
+class B : public A {
+public:
+  B() = default;
+
+  // Nothing to fix: calls to direct parent.
+  int virt_1() override { return A::virt_1() + 3; }
+  int virt_2() override { return A::virt_2() + 4; }
+};
+
+class C : public B {
+public:
+  int virt_1() override { return A::virt_1() + B::virt_1(); }
+  // CHECK-MESSAGES: :[[@LINE-1]]:34: warning: qualified name 'A::virt_1' refers to a member overridden in subclass; did you mean 'B'? [bugprone-parent-virtual-call]
+  // CHECK-FIXES:  int virt_1() override { return B::virt_1() + B::virt_1(); }
+  int virt_2() override { return A::virt_1() + B::virt_1(); }
+  // CHECK-MESSAGES: :[[@LINE-1]]:34: warning: qualified name 'A::virt_1' {{.*}}; did you mean 'B'? {{.*}}
+  // CHECK-FIXES:  int virt_2() override { return B::virt_1() + B::virt_1(); }
+
+  // Test that non-virtual and static methods are not affected by this cherker.
+  int method_c() { return A::stat() + A::non_virt(); }
+};
+
+// Check aliased type names
+using A1 = A;
+typedef A A2;
+#define A3 A
+
+class C2 : public B {
+public:
+  int virt_1() override { return A1::virt_1() + A2::virt_1() + A3::virt_1(); }
+  // CHECK-MESSAGES: :[[@LINE-1]]:34: warning: qualified name 'A1::virt_1' {{.*}}; did you mean 'B'? {{.*}}
+  // CHECK-MESSAGES: :[[@LINE-2]]:49: warning: qualified name 'A2::virt_1' {{.*}}; did you mean 'B'? {{.*}}
+  // CHECK-MESSAGES: :[[@LINE-3]]:64: warning: qualified name 'A3::virt_1' {{.*}}; did you mean 'B'? {{.*}}
+  // CHECK-FIXES:  int virt_1() override { return B::virt_1() + B::virt_1() + B::virt_1(); }
+};
+
+// Test that the check affects grand-grand..-parent calls too.
+class D : public C {
+public:
+  int virt_1() override { return A::virt_1() + B::virt_1() + D::virt_1(); }
+  // CHECK-MESSAGES: :[[@LINE-1]]:34: warning: qualified name 'A::virt_1' {{.*}}; did you mean 'C'? {{.*}}
+  // CHECK-MESSAGES: :[[@LINE-2]]:48: warning: qualified name 'B::virt_1' {{.*}}; did you mean 'C'? {{.*}}
+  // CHECK-FIXES:  int virt_1() override { return C::virt_1() + C::virt_1() + D::virt_1(); }
+  int virt_2() override { return A::virt_1() + B::virt_1() + D::virt_1(); }
+  // CHECK-MESSAGES: :[[@LINE-1]]:34: warning: qualified name 'A::virt_1' {{.*}}; did you mean 'C'? {{.*}}
+  // CHECK-MESSAGES: :[[@LINE-2]]:48: warning: qualified name 'B::virt_1' {{.*}}; did you mean 'C'? {{.*}}
+  // CHECK-FIXES:  int virt_2() override { return C::virt_1() + C::virt_1() + D::virt_1(); }
+};
+
+// Test classes in namespaces.
+namespace {
+class BN : public A {
+public:
+  int virt_1() override { return A::virt_1() + 3; }
+  int virt_2() override { return A::virt_2() + 4; }
+};
+} // namespace
+
+namespace N1 {
+class A {
+public:
+  A() = default;
+  virtual int virt_1() { return foo() + 1; }
+  virtual int virt_2() { return foo() + 2; }
+};
+} // namespace N1
+
+namespace N2 {
+class BN : public N1::A {
+public:
+  int virt_1() override { return A::virt_1() + 3; }
+  int virt_2() override { return A::virt_2() + 4; }
+};
+} // namespace N2
+
+class CN : public BN {
+public:
+  int virt_1() override { return A::virt_1() + BN::virt_1(); }
+  // CHECK-MESSAGES: :[[@LINE-1]]:34: warning: qualified name 'A::virt_1' {{.*}}; did you mean 'BN'? {{.*}}
+  // CHECK-FIXES:  int virt_1() override { return BN::virt_1() + BN::virt_1(); }
+  int virt_2() override { return A::virt_1() + BN::virt_1(); }
+  // CHECK-MESSAGES: :[[@LINE-1]]:34: warning: qualified name 'A::virt_1' {{.*}}; did you mean 'BN'? {{.*}}
+  // CHECK-FIXES:  int virt_2() override { return BN::virt_1() + BN::virt_1(); }
+};
+
+class CNN : public N2::BN {
+public:
+  int virt_1() override { return N1::A::virt_1() + N2::BN::virt_1(); }
+  // CHECK-MESSAGES: :[[@LINE-1]]:34: warning: qualified name 'N1::A::virt_1' {{.*}}; did you mean 'N2::BN'? {{.*}}
+  // CHECK-FIXES:  int virt_1() override { return N2::BN::virt_1() + N2::BN::virt_1(); }
+  int virt_2() override { re

[PATCH] D45096: Allow the creation of human-friendly ASTDumper to arbitrary output stream

2018-04-05 Thread Whisperity via Phabricator via cfe-commits
whisperity added a comment.

@alexfh I have updated the patch. I don't have commit rights, so if you think 
this is good to go, could you please commit for me?


Repository:
  rC Clang

https://reviews.llvm.org/D45096



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


[PATCH] D45233: [Driver] Update GCC libraries detection logic for Gentoo.

2018-04-05 Thread Michał Górny via Phabricator via cfe-commits
mgorny added a comment.

Ok, I've tried it on top of clang-6.0.0 and I get the following test failures:

  Failing Tests (8):
  Clang :: Driver/android-ndk-standalone.cpp
  Clang :: Driver/constructors.c
  Clang :: Driver/cuda-detect.cu
  Clang :: Driver/env.c
  Clang :: Driver/gcc-version-debug.c
  Clang :: Driver/linux-header-search.cpp
  Clang :: Driver/linux-ld.c
  Clang :: Driver/pic.c

Could you check whether the tests pass for you? Me using 6.0.0 may be the 
culprit here but I don't think it should have such significant effect.


Repository:
  rC Clang

https://reviews.llvm.org/D45233



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


[PATCH] D45240: [ARM] Compute a target feature which corresponds to the ARM version.

2018-04-05 Thread Eli Friedman via Phabricator via cfe-commits
efriedma added inline comments.



Comment at: lib/Basic/Targets/ARM.cpp:345
   // get default FPU features
+  llvm::ARM::ArchKind Arch = llvm::ARM::parseArch(getTriple().getArchName());
   unsigned FPUKind = llvm::ARM::getDefaultFPU(CPU, Arch);

fhahn wrote:
> Is there a reason we re-compute the Arch from the triple here, but use the 
> member variable ArchKind above? Shouldn't they both be the same ?
ArchKind is based on the triple and the CPU, where "Arch" is just based on the 
triple, so "Arch" was returning the wrong thing in some cases.

Actually, looking a bit more, we should probably be calling parseCPUArch here 
to get the right behavior, rather than depending on the member.  (It doesn't 
usually matter, but it could make a difference for code using "target" 
attribute, I guess.  That feature needs a lot more work, though.)


Repository:
  rC Clang

https://reviews.llvm.org/D45240



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


Re: r328680 - [ObjC] Make C++ triviality type traits available to non-trivial C

2018-04-05 Thread Akira Hatanaka via cfe-commits

> On Apr 5, 2018, at 12:39 PM, John McCall  wrote:
> 
> 
> 
>> On Apr 4, 2018, at 7:37 PM, Akira Hatanaka > > wrote:
>> 
>> 
>> 
>>> On Apr 4, 2018, at 4:24 PM, Akira Hatanaka via cfe-commits 
>>> mailto:cfe-commits@lists.llvm.org>> wrote:
>>> 
 
 On Apr 4, 2018, at 3:38 PM, Richard Smith >>> > wrote:
 
 Hi Akira,
 
 This change has broken the C++ versions of these type traits for classes 
 with volatile members. Such classes are required to claim to be trivial 
 per C++ DR 2094 
 (http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#2094 
 ) but 
 return false from isNonTrivialToPrimitiveCopy().
 
>>> 
>>> Oh that’s right. The function returns false when 
>>> isNonTrivialToPrimitiveCopy() returns PCK_VolatileTrivial. That is wrong.
>>> 
 Also, exposing these __has_* traits more widely seems like a backwards 
 step to me: these traits are deprecated, near-useless, and we're trying to 
 remove them. No code should be using them under any circumstances; the 
 __is_* traits should be used instead.
 
>>> 
>>> The __is_* traits (is_trivially_copy_constructible, etc.) are templates 
>>> defined in libcxx, so it seems that we can’t use them when compiling in C 
>>> mode. Is it OK to add their definitions to TokenKinds.def as non-C++ 
>>> keywords?
>>> 
>> 
>> Or perhaps redefine the six __has_* traits used here as non-C++ (KEYNOCXX or 
>> ‘KEYC99 | KEYC11') keywords?
> 
> I think Richard is talking about e.g. the __is_trivially_destructible 
> intrinsic type trait function rather than std::is_trivially_destructible.
> 
> Do we have a concrete need to expose these type traits to C?
> 

No, no one has asked any of these type traits to be exposed to C yet. Do you 
think we should just revert the patch and wait until someone asks for those 
type traits to be available in C?

> John.
> 
>> 
 On 27 March 2018 at 17:12, Akira Hatanaka via cfe-commits 
 mailto:cfe-commits@lists.llvm.org>> wrote:
 Author: ahatanak
 Date: Tue Mar 27 17:12:08 2018
 New Revision: 328680
 
 URL: http://llvm.org/viewvc/llvm-project?rev=328680&view=rev 
 
 Log:
 [ObjC] Make C++ triviality type traits available to non-trivial C
 structs.
 
 r326307 and r327870 made changes that allowed using non-trivial C
 structs with fields qualified with __strong or __weak. This commit makes
 the following C++ triviality type traits available to non-trivial C
 structs:
 
 __has_trivial_assign
 __has_trivial_move_assign
 __has_trivial_copy
 __has_trivial_move_constructor
 __has_trivial_constructor
 __has_trivial_destructor
 
 rdar://problem/33599681 
 
 Differential Revision: https://reviews.llvm.org/D44913 
 
 
 Added:
 cfe/trunk/test/SemaObjC/non-trivial-struct-traits.m
 Modified:
 cfe/trunk/include/clang/Basic/TokenKinds.def
 cfe/trunk/lib/Sema/SemaExprCXX.cpp
 
 Modified: cfe/trunk/include/clang/Basic/TokenKinds.def
 URL: 
 http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/TokenKinds.def?rev=328680&r1=328679&r2=328680&view=diff
  
 
 ==
 --- cfe/trunk/include/clang/Basic/TokenKinds.def (original)
 +++ cfe/trunk/include/clang/Basic/TokenKinds.def Tue Mar 27 17:12:08 2018
 @@ -433,12 +433,12 @@ TYPE_TRAIT_1(__has_nothrow_assign, HasNo
  TYPE_TRAIT_1(__has_nothrow_move_assign, HasNothrowMoveAssign, KEYCXX)
  TYPE_TRAIT_1(__has_nothrow_copy, HasNothrowCopy, KEYCXX)
  TYPE_TRAIT_1(__has_nothrow_constructor, HasNothrowConstructor, KEYCXX)
 -TYPE_TRAIT_1(__has_trivial_assign, HasTrivialAssign, KEYCXX)
 -TYPE_TRAIT_1(__has_trivial_move_assign, HasTrivialMoveAssign, KEYCXX)
 -TYPE_TRAIT_1(__has_trivial_copy, HasTrivialCopy, KEYCXX)
 -TYPE_TRAIT_1(__has_trivial_constructor, HasTrivialDefaultConstructor, 
 KEYCXX)
 -TYPE_TRAIT_1(__has_trivial_move_constructor, HasTrivialMoveConstructor, 
 KEYCXX)
 -TYPE_TRAIT_1(__has_trivial_destructor, HasTrivialDestructor, KEYCXX)
 +TYPE_TRAIT_1(__has_trivial_assign, HasTrivialAssign, KEYALL)
 +TYPE_TRAIT_1(__has_trivial_move_assign, HasTrivialMoveAssign, KEYALL)
 +TYPE_TRAIT_1(__has_trivial_copy, HasTrivialCopy, KEYALL)
 +TYPE_TRAIT_1(__has_trivial_constructor, HasTrivialDefaultConstructor, 
 KEYALL)
 +TYPE_TRAIT_1(__has_trivial_move_constructor, HasTrivialMoveConstructor, 
 KEYALL)
 +TYPE_TRAIT_1(__has_trivial_destructor, HasTrivialDestructor, KEYALL)
  TYPE_TRAIT_1(__h

[PATCH] D45094: [LibTooling] Make interface of VFS injection into ClangTool more user-friendly

2018-04-05 Thread Whisperity via Phabricator via cfe-commits
whisperity updated this revision to Diff 141204.
whisperity added a comment.

- Use an even more explicit way with the documentation requiring that the file 
system should be an overlay.
- Add a method to easily overlay a `FileSystem` above the real one.


Repository:
  rC Clang

https://reviews.llvm.org/D45094

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

Index: unittests/Tooling/ToolingTest.cpp
===
--- unittests/Tooling/ToolingTest.cpp
+++ unittests/Tooling/ToolingTest.cpp
@@ -402,24 +402,39 @@
   EXPECT_FALSE(Found);
 }
 
-TEST(ClangToolTest, BaseVirtualFileSystemUsage) {
+TEST(ClangToolVFSTest, VirtualFileSystemUsage) {
   FixedCompilationDatabase Compilations("/", std::vector());
-  llvm::IntrusiveRefCntPtr OverlayFileSystem(
-  new vfs::OverlayFileSystem(vfs::getRealFileSystem()));
   llvm::IntrusiveRefCntPtr InMemoryFileSystem(
   new vfs::InMemoryFileSystem);
-  OverlayFileSystem->pushOverlay(InMemoryFileSystem);
 
   InMemoryFileSystem->addFile(
-  "a.cpp", 0, llvm::MemoryBuffer::getMemBuffer("int main() {}"));
+  "/a.cpp", 0, llvm::MemoryBuffer::getMemBuffer("int main() {}"));
 
-  ClangTool Tool(Compilations, std::vector(1, "a.cpp"),
- std::make_shared(), OverlayFileSystem);
+  ClangTool Tool(Compilations, std::vector(1, "/a.cpp"),
+ std::make_shared(),
+ InMemoryFileSystem);
   std::unique_ptr Action(
   newFrontendActionFactory());
   EXPECT_EQ(0, Tool.run(Action.get()));
 }
 
+TEST(ClangToolVFSTest, VFSDoesntContainEveryFile) {
+  FixedCompilationDatabase Compilations("/", std::vector());
+  llvm::IntrusiveRefCntPtr InMemoryFileSystem(
+  new vfs::InMemoryFileSystem);
+
+  InMemoryFileSystem->addFile(
+  "/a.cpp", 0, llvm::MemoryBuffer::getMemBuffer("#include \n"
+"int main() {}"));
+
+  ClangTool Tool(Compilations, std::vector(1, "/a.cpp"),
+ std::make_shared(),
+ InMemoryFileSystem);
+  std::unique_ptr Action(
+  newFrontendActionFactory());
+  EXPECT_NE(0, Tool.run(Action.get()));
+}
+
 // Check getClangStripDependencyFileAdjuster doesn't strip args after -MD/-MMD.
 TEST(ClangToolTest, StripDependencyFileAdjuster) {
   FixedCompilationDatabase Compilations("/", {"-MD", "-c", "-MMD", "-w"});
Index: lib/Tooling/Tooling.cpp
===
--- lib/Tooling/Tooling.cpp
+++ lib/Tooling/Tooling.cpp
@@ -358,13 +358,13 @@
 ClangTool::ClangTool(const CompilationDatabase &Compilations,
  ArrayRef SourcePaths,
  std::shared_ptr PCHContainerOps,
- IntrusiveRefCntPtr BaseFS)
+ IntrusiveRefCntPtr FileSystem)
 : Compilations(Compilations), SourcePaths(SourcePaths),
   PCHContainerOps(std::move(PCHContainerOps)),
-  OverlayFileSystem(new vfs::OverlayFileSystem(std::move(BaseFS))),
-  InMemoryFileSystem(new vfs::InMemoryFileSystem),
-  Files(new FileManager(FileSystemOptions(), OverlayFileSystem)) {
+  InMemoryFileSystem(new vfs::InMemoryFileSystem) {
+  OverlayFileSystem = new vfs::OverlayFileSystem(FileSystem);
   OverlayFileSystem->pushOverlay(InMemoryFileSystem);
+  Files = new FileManager(FileSystemOptions(), OverlayFileSystem);
   appendArgumentsAdjuster(getClangStripOutputAdjuster());
   appendArgumentsAdjuster(getClangSyntaxOnlyAdjuster());
   appendArgumentsAdjuster(getClangStripDependencyFileAdjuster());
Index: lib/Basic/VirtualFileSystem.cpp
===
--- lib/Basic/VirtualFileSystem.cpp
+++ lib/Basic/VirtualFileSystem.cpp
@@ -325,6 +325,7 @@
 }
 
 void OverlayFileSystem::pushOverlay(IntrusiveRefCntPtr FS) {
+  // FIXME: OverlayFS containing another one in its stack could be flattened.
   FSList.push_back(FS);
   // Synchronize added file systems by duplicating the working directory from
   // the first one in the list.
@@ -366,6 +367,14 @@
   return {};
 }
 
+IntrusiveRefCntPtr
+vfs::createOverlayOnRealFilesystem(IntrusiveRefCntPtr TopFS) {
+  IntrusiveRefCntPtr OverlayFS =
+new OverlayFileSystem(getRealFileSystem());
+  OverlayFS->pushOverlay(TopFS);
+  return OverlayFS;
+}
+
 clang::vfs::detail::DirIterImpl::~DirIterImpl() = default;
 
 namespace {
Index: include/clang/Tooling/Tooling.h
===
--- include/clang/Tooling/Tooling.h
+++ include/clang/Tooling/Tooling.h
@@ -303,14 +303,16 @@
   /// \param SourcePaths The source files to run over. If a source files is
   ///not found in Compilations, it is skipped.
   /// \param PCHContainerOps The PCHContainerOperations for loading and creating
-  /// clang modules.
-  /// \param BaseFS VFS used for all underlyin

[PATCH] D42092: implement C++ dr388 for the Itanium C++ ABI: proper handling of catching exceptions by reference

2018-04-05 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith abandoned this revision.
rsmith added a comment.

In https://reviews.llvm.org/D42092#1058772, @rjmccall wrote:

> Issue #3 is tricky; it's arguably not okay to force a landing at a landing 
> pad if we're not actually catching anything.


I think the only way this is observable (at least within the bounds of 
well-defined C++ code) is whether -- and how much -- the stack is unwound 
before a call to `terminate()` in the case where an exception is not caught.

[except.handle]p9 says: "If no matching handler is found, the function 
std::terminate() is called; whether or not the stack is unwound before this 
call to std::terminate() is implementation-defined (18.5.1)."
[except.terminate]p2 says: " In the situation where no matching handler is 
found, it is implementation-defined whether or not the stack is unwound before 
std::terminate() is called. In the situation where the search for a handler 
(18.3) encounters the outermost block of a function with a non-throwing 
exception specification (18.4), it is implementation-defined whether the stack 
is unwound, unwound partially, or not unwound at all before std::terminate() is 
called. In all other situations, the stack shall not be unwound before 
std::terminate() is called."

So I think you're right; this solution to issue #3 is non-conforming, because 
it will result in the stack being partially unwound on the path to a call to 
`std::terminate()` for an unhandled exception. Even if we changed the rule for 
`terminate` to allow partial unwinding when no handler is found, this patch 
would still give a QoI regression for that case (because the call to the 
`terminate_handler` would happen after some unwinding had been performed).

I'm not particularly interested in pushing this patch further if it can't 
actually make catch-by-reference work properly. Let's drop this for now and 
encourage interested parties to work on an alternative personality function.


Repository:
  rC Clang

https://reviews.llvm.org/D42092



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


[PATCH] D45306: PR36992 don't overwrite virtual bases in tail padding

2018-04-05 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith updated this revision to Diff 141205.
rsmith marked 2 inline comments as done.

https://reviews.llvm.org/D45306

Files:
  CodeGen/CGAtomic.cpp
  CodeGen/CGBlocks.cpp
  CodeGen/CGCall.cpp
  CodeGen/CGClass.cpp
  CodeGen/CGDecl.cpp
  CodeGen/CGDeclCXX.cpp
  CodeGen/CGExpr.cpp
  CodeGen/CGExprAgg.cpp
  CodeGen/CGExprCXX.cpp
  CodeGen/CGObjC.cpp
  CodeGen/CGOpenMPRuntime.cpp
  CodeGen/CGStmt.cpp
  CodeGen/CGValue.h
  CodeGen/CodeGenFunction.h
  CodeGen/ItaniumCXXABI.cpp
  CodeGenCXX/tail-padding.cpp

Index: CodeGenCXX/tail-padding.cpp
===
--- /dev/null
+++ CodeGenCXX/tail-padding.cpp
@@ -0,0 +1,34 @@
+// RUN: %clang_cc1 -triple %itanium_abi_triple -emit-llvm -o - %s | FileCheck %s
+
+// PR36992
+namespace Implicit {
+  struct A { char c; A(const A&); };
+  struct B { int n; char c[3]; ~B(); };
+  struct C : B, virtual A {};
+  static_assert(sizeof(C) == sizeof(void*) + 8);
+  C f(C c) { return c; }
+
+  // CHECK: define {{.*}} @_ZN8Implicit1CC1EOS0_
+  // CHECK: call void @_ZN8Implicit1AC2ERKS0_(
+  // Note: this must memcpy 7 bytes, not 8, to avoid trampling over the virtual base class.
+  // CHECK: call void @llvm.memcpy.p0i8.p0i8.i64(i8* {{.*}}, i8* {{.*}}, i64 7, i1 false)
+  // CHECK: store i32 {{.*}} @_ZTVN8Implicit1CE
+}
+
+namespace InitWithinNVSize {
+  // This is the same as the previous test, except that the A base lies
+  // entirely within the nvsize of C. This makes it valid to copy at the
+  // full width.
+  struct A { char c; A(const A&); };
+  struct B { int n; char c[3]; ~B(); };
+  struct C : B, virtual A { char x; };
+  static_assert(sizeof(C) > sizeof(void*) + 8);
+  C f(C c) { return c; }
+
+  // CHECK: define {{.*}} @_ZN16InitWithinNVSize1CC1EOS0_
+  // CHECK: call void @_ZN16InitWithinNVSize1AC2ERKS0_(
+  // This copies over the 'C::x' member, but that's OK because we've not initialized it yet.
+  // CHECK: call void @llvm.memcpy.p0i8.p0i8.i64(i8* {{.*}}, i8* {{.*}}, i64 8, i1 false)
+  // CHECK: store i32 {{.*}} @_ZTVN16InitWithinNVSize1CE
+  // CHECK: store i8
+}
Index: CodeGen/ItaniumCXXABI.cpp
===
--- CodeGen/ItaniumCXXABI.cpp
+++ CodeGen/ItaniumCXXABI.cpp
@@ -3896,7 +3896,7 @@
 caughtExnAlignment);
 LValue Dest = CGF.MakeAddrLValue(ParamAddr, CatchType);
 LValue Src = CGF.MakeAddrLValue(adjustedExn, CatchType);
-CGF.EmitAggregateCopy(Dest, Src, CatchType);
+CGF.EmitAggregateCopy(Dest, Src, CatchType, AggValueSlot::DoesNotOverlap);
 return;
   }
 
@@ -3923,7 +3923,8 @@
   AggValueSlot::forAddr(ParamAddr, Qualifiers(),
 AggValueSlot::IsNotDestructed,
 AggValueSlot::DoesNotNeedGCBarriers,
-AggValueSlot::IsNotAliased));
+AggValueSlot::IsNotAliased,
+AggValueSlot::DoesNotOverlap));
 
   // Leave the terminate scope.
   CGF.EHStack.popTerminate();
Index: CodeGen/CodeGenFunction.h
===
--- CodeGen/CodeGenFunction.h
+++ CodeGen/CodeGenFunction.h
@@ -2061,7 +2061,8 @@
  T.getQualifiers(),
  AggValueSlot::IsNotDestructed,
  AggValueSlot::DoesNotNeedGCBarriers,
- AggValueSlot::IsNotAliased);
+ AggValueSlot::IsNotAliased,
+ AggValueSlot::DoesNotOverlap);
   }
 
   /// Emit a cast to void* in the appropriate address space.
@@ -2118,28 +2119,52 @@
 }
 return false;
   }
-  /// EmitAggregateCopy - Emit an aggregate assignment.
-  ///
-  /// The difference to EmitAggregateCopy is that tail padding is not copied.
-  /// This is required for correctness when assigning non-POD structures in C++.
+
+  /// Determine whether a return value slot may overlap some other object.
+  AggValueSlot::Overlap_t overlapForReturnValue() {
+// FIXME: Assuming no overlap here breaks guaranteed copy elision for base
+// class subobjects. These cases may need to be revisited depending on the
+// resolution of the relevant core issue.
+return AggValueSlot::DoesNotOverlap;
+  }
+
+  /// Determine whether a field initialization may overlap some other object.
+  AggValueSlot::Overlap_t overlapForFieldInit(const FieldDecl *FD) {
+// FIXME: These cases can result in overlap as a result of P0840R0's
+// [[no_unique_address]] attribute. We can still infer NoOverlap in the
+// presence of that attribute if the field is within the nvsize of its
+// containing class, because non-virtual subobjects are initialized in
+// address order.
+return AggValueSlot::DoesNotOverlap;
+  }
+
+  /// Determine whether a base class initialization may overlap s

[PATCH] D45306: PR36992 don't overwrite virtual bases in tail padding

2018-04-05 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith added a comment.

In https://reviews.llvm.org/D45306#1058792, @rjmccall wrote:

> Changing the requirements on the return-value slot would be an ABI break, no?


It would be, yes. But WG21 seems to have a taste for breaking changes at the 
moment, so who knows... I'm happy to remove `overlapForReturnValue` for now; 
it's easy enough to find these places again should the change ever happen.

> And it would force to us to treat all complete-object constructions as 
> nvsize-limited unless they're constructions of known sizeof-sized allocations.

P0840 pushes us there already. Fortunately, we don't treat complete-object 
constructors specially in this regard currently, and no other compiler seems to 
do so either. However, when performing the trivial copy/move constructor -> 
`memcpy` optimization (which is I think the most interesting case for extending 
a store into the tail padding), we do know which object is being initialized, 
so we can take into account whether it could have something else allocated into 
its tail padding.




Comment at: CodeGen/CGDecl.cpp:1462
+  AggValueSlot::IsNotAliased,
+  AggValueSlot::DoesNotOverlap));
 }

rjmccall wrote:
> How is 'does not overlap' justified here?  Should this be propagated into the 
> LValue?
That's what I get for trusting comments :)

No functional change from `DoesNotOverlap` here yet, though, because in 
practice this is always called with some kind of `VarDecl` (which is 
`DoesNotOverlap` because it's a complete object) or some kind of `FieldDecl` 
(which is `DoesNotOverlap` until P0840 lands).


https://reviews.llvm.org/D45306



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


[PATCH] D45094: [LibTooling] Make interface of VFS injection into ClangTool more user-friendly

2018-04-05 Thread Whisperity via Phabricator via cfe-commits
whisperity updated this revision to Diff 141206.
whisperity added a comment.

Simplify the patch.


https://reviews.llvm.org/D45094

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

Index: unittests/Tooling/ToolingTest.cpp
===
--- unittests/Tooling/ToolingTest.cpp
+++ unittests/Tooling/ToolingTest.cpp
@@ -402,24 +402,39 @@
   EXPECT_FALSE(Found);
 }
 
-TEST(ClangToolTest, BaseVirtualFileSystemUsage) {
+TEST(ClangToolVFSTest, VirtualFileSystemUsage) {
   FixedCompilationDatabase Compilations("/", std::vector());
-  llvm::IntrusiveRefCntPtr OverlayFileSystem(
-  new vfs::OverlayFileSystem(vfs::getRealFileSystem()));
   llvm::IntrusiveRefCntPtr InMemoryFileSystem(
   new vfs::InMemoryFileSystem);
-  OverlayFileSystem->pushOverlay(InMemoryFileSystem);
 
   InMemoryFileSystem->addFile(
-  "a.cpp", 0, llvm::MemoryBuffer::getMemBuffer("int main() {}"));
+  "/a.cpp", 0, llvm::MemoryBuffer::getMemBuffer("int main() {}"));
 
-  ClangTool Tool(Compilations, std::vector(1, "a.cpp"),
- std::make_shared(), OverlayFileSystem);
+  ClangTool Tool(Compilations, std::vector(1, "/a.cpp"),
+ std::make_shared(),
+ InMemoryFileSystem);
   std::unique_ptr Action(
   newFrontendActionFactory());
   EXPECT_EQ(0, Tool.run(Action.get()));
 }
 
+TEST(ClangToolVFSTest, VFSDoesntContainEveryFile) {
+  FixedCompilationDatabase Compilations("/", std::vector());
+  llvm::IntrusiveRefCntPtr InMemoryFileSystem(
+  new vfs::InMemoryFileSystem);
+
+  InMemoryFileSystem->addFile(
+  "/a.cpp", 0, llvm::MemoryBuffer::getMemBuffer("#include \n"
+"int main() {}"));
+
+  ClangTool Tool(Compilations, std::vector(1, "/a.cpp"),
+ std::make_shared(),
+ InMemoryFileSystem);
+  std::unique_ptr Action(
+  newFrontendActionFactory());
+  EXPECT_NE(0, Tool.run(Action.get()));
+}
+
 // Check getClangStripDependencyFileAdjuster doesn't strip args after -MD/-MMD.
 TEST(ClangToolTest, StripDependencyFileAdjuster) {
   FixedCompilationDatabase Compilations("/", {"-MD", "-c", "-MMD", "-w"});
Index: lib/Tooling/Tooling.cpp
===
--- lib/Tooling/Tooling.cpp
+++ lib/Tooling/Tooling.cpp
@@ -358,10 +358,10 @@
 ClangTool::ClangTool(const CompilationDatabase &Compilations,
  ArrayRef SourcePaths,
  std::shared_ptr PCHContainerOps,
- IntrusiveRefCntPtr BaseFS)
+ IntrusiveRefCntPtr FileSystem)
 : Compilations(Compilations), SourcePaths(SourcePaths),
   PCHContainerOps(std::move(PCHContainerOps)),
-  OverlayFileSystem(new vfs::OverlayFileSystem(std::move(BaseFS))),
+  OverlayFileSystem(new vfs::OverlayFileSystem(std::move(FileSystem))),
   InMemoryFileSystem(new vfs::InMemoryFileSystem),
   Files(new FileManager(FileSystemOptions(), OverlayFileSystem)) {
   OverlayFileSystem->pushOverlay(InMemoryFileSystem);
Index: lib/Basic/VirtualFileSystem.cpp
===
--- lib/Basic/VirtualFileSystem.cpp
+++ lib/Basic/VirtualFileSystem.cpp
@@ -325,6 +325,7 @@
 }
 
 void OverlayFileSystem::pushOverlay(IntrusiveRefCntPtr FS) {
+  // FIXME: OverlayFS containing another one in its stack could be flattened.
   FSList.push_back(FS);
   // Synchronize added file systems by duplicating the working directory from
   // the first one in the list.
@@ -366,6 +367,14 @@
   return {};
 }
 
+IntrusiveRefCntPtr
+vfs::createOverlayOnRealFilesystem(IntrusiveRefCntPtr TopFS) {
+  IntrusiveRefCntPtr OverlayFS =
+new OverlayFileSystem(getRealFileSystem());
+  OverlayFS->pushOverlay(TopFS);
+  return OverlayFS;
+}
+
 clang::vfs::detail::DirIterImpl::~DirIterImpl() = default;
 
 namespace {
Index: include/clang/Tooling/Tooling.h
===
--- include/clang/Tooling/Tooling.h
+++ include/clang/Tooling/Tooling.h
@@ -303,14 +303,16 @@
   /// \param SourcePaths The source files to run over. If a source files is
   ///not found in Compilations, it is skipped.
   /// \param PCHContainerOps The PCHContainerOperations for loading and creating
-  /// clang modules.
-  /// \param BaseFS VFS used for all underlying file accesses when running the
-  /// tool.
+  ///clang modules.
+  /// \param FileSystem The Virtual File System that is used to retrieve file
+  ///contents by the tool. In most cases, this should be an overlay upon
+  ///the real file system. (See \p vfs::createOverlayOnRealFilesystem
+  ///for easily creating an overlay.)
   ClangTool(const CompilationDatabase &Compilations,
 ArrayRef SourcePaths,
 std::shared_

[PATCH] D45095: [clang-tidy] Align usage of ClangTool interface with new VFS injection

2018-04-05 Thread Whisperity via Phabricator via cfe-commits
whisperity updated this revision to Diff 141207.
whisperity added a comment.

Update to be in line with contents in dependency patch.


https://reviews.llvm.org/D45095

Files:
  clang-tidy/ClangTidy.cpp
  clang-tidy/ClangTidy.h
  clang-tidy/tool/CMakeLists.txt
  clang-tidy/tool/ClangTidyMain.cpp

Index: clang-tidy/tool/ClangTidyMain.cpp
===
--- clang-tidy/tool/ClangTidyMain.cpp
+++ clang-tidy/tool/ClangTidyMain.cpp
@@ -339,10 +339,8 @@
 
 llvm::IntrusiveRefCntPtr
 getVfsOverlayFromFile(const std::string &OverlayFile) {
-  llvm::IntrusiveRefCntPtr OverlayFS(
-  new vfs::OverlayFileSystem(vfs::getRealFileSystem()));
   llvm::ErrorOr> Buffer =
-  OverlayFS->getBufferForFile(OverlayFile);
+  vfs::getRealFileSystem()->getBufferForFile(OverlayFile);
   if (!Buffer) {
 llvm::errs() << "Can't load virtual filesystem overlay file '"
  << OverlayFile << "': " << Buffer.getError().message()
@@ -357,8 +355,7 @@
  << OverlayFile << "'.\n";
 return nullptr;
   }
-  OverlayFS->pushOverlay(FS);
-  return OverlayFS;
+  return FS;
 }
 
 static int clangTidyMain(int argc, const char **argv) {
@@ -432,10 +429,10 @@
 llvm::cl::PrintHelpMessage(/*Hidden=*/false, /*Categorized=*/true);
 return 1;
   }
-  llvm::IntrusiveRefCntPtr BaseFS(
-  VfsOverlay.empty() ? vfs::getRealFileSystem()
+  llvm::IntrusiveRefCntPtr VirtualFileSystem(
+  VfsOverlay.empty() ? nullptr
  : getVfsOverlayFromFile(VfsOverlay));
-  if (!BaseFS)
+  if (!VfsOverlay.empty() && !VirtualFileSystem)
 return 1;
 
   ProfileData Profile;
@@ -445,8 +442,10 @@
   llvm::InitializeAllAsmParsers();
 
   ClangTidyContext Context(std::move(OwningOptionsProvider));
-  runClangTidy(Context, OptionsParser.getCompilations(), PathList, BaseFS,
-   EnableCheckProfile ? &Profile : nullptr);
+  ClangTool Tool(OptionsParser.getCompilations(), PathList,
+ std::make_shared(),
+ vfs::createOverlayOnRealFilesystem(VirtualFileSystem));
+  runClangTidy(Context, Tool, EnableCheckProfile ? &Profile : nullptr);
   ArrayRef Errors = Context.getErrors();
   bool FoundErrors =
   std::find_if(Errors.begin(), Errors.end(), [](const ClangTidyError &E) {
@@ -459,7 +458,7 @@
 
   // -fix-errors implies -fix.
   handleErrors(Context, (FixErrors || Fix) && !DisableFixes, WErrorCount,
-   BaseFS);
+   Tool);
 
   if (!ExportFixes.empty() && !Errors.empty()) {
 std::error_code EC;
Index: clang-tidy/tool/CMakeLists.txt
===
--- clang-tidy/tool/CMakeLists.txt
+++ clang-tidy/tool/CMakeLists.txt
@@ -16,6 +16,7 @@
   clangAST
   clangASTMatchers
   clangBasic
+  clangFrontend
   clangTidy
   clangTidyAndroidModule
   clangTidyAbseilModule
Index: clang-tidy/ClangTidy.h
===
--- clang-tidy/ClangTidy.h
+++ clang-tidy/ClangTidy.h
@@ -16,6 +16,7 @@
 #include "clang/Basic/Diagnostic.h"
 #include "clang/Basic/SourceManager.h"
 #include "clang/Tooling/Refactoring.h"
+#include "clang/Tooling/Tooling.h"
 #include "llvm/ADT/StringExtras.h"
 #include "llvm/Support/raw_ostream.h"
 #include 
@@ -225,9 +226,7 @@
 /// \param Profile if provided, it enables check profile collection in
 /// MatchFinder, and will contain the result of the profile.
 void runClangTidy(clang::tidy::ClangTidyContext &Context,
-  const tooling::CompilationDatabase &Compilations,
-  ArrayRef InputFiles,
-  llvm::IntrusiveRefCntPtr BaseFS,
+  clang::tooling::ClangTool &Tool,
   ProfileData *Profile = nullptr);
 
 // FIXME: This interface will need to be significantly extended to be useful.
@@ -238,7 +237,7 @@
 /// clang-format configuration file is found, the given \P FormatStyle is used.
 void handleErrors(ClangTidyContext &Context, bool Fix,
   unsigned &WarningsAsErrorsCount,
-  llvm::IntrusiveRefCntPtr BaseFS);
+  clang::tooling::ClangTool &Tool);
 
 /// \brief Serializes replacements into YAML and writes them to the specified
 /// output stream.
Index: clang-tidy/ClangTidy.cpp
===
--- clang-tidy/ClangTidy.cpp
+++ clang-tidy/ClangTidy.cpp
@@ -38,7 +38,6 @@
 #include "clang/Tooling/DiagnosticsYaml.h"
 #include "clang/Tooling/Refactoring.h"
 #include "clang/Tooling/ReplacementsYaml.h"
-#include "clang/Tooling/Tooling.h"
 #include "llvm/Support/Process.h"
 #include "llvm/Support/Signals.h"
 #include 
@@ -89,9 +88,9 @@
 
 class ErrorReporter {
 public:
-  ErrorReporter(ClangTidyContext &Context, bool ApplyFixes,
-llvm::IntrusiveRefCntPtr BaseFS)
-  : Files(FileSystemOptions(), BaseFS), DiagOpts(new DiagnosticOptions()),
+  ErrorReporter(ClangTidyContext &Context, bool ApplyFixes, Cla

[PATCH] D45306: PR36992 don't overwrite virtual bases in tail padding

2018-04-05 Thread John McCall via Phabricator via cfe-commits
rjmccall accepted this revision.
rjmccall added a comment.
This revision is now accepted and ready to land.

Okay, LGTM.


https://reviews.llvm.org/D45306



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


[PATCH] D44330: CMake option to allow enabling experimental new pass manager by default

2018-04-05 Thread Chandler Carruth via Phabricator via cfe-commits
chandlerc accepted this revision.
chandlerc added a comment.
This revision is now accepted and ready to land.

Meh, I think this is fine as-is.


Repository:
  rC Clang

https://reviews.llvm.org/D44330



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


[PATCH] D42092: implement C++ dr388 for the Itanium C++ ABI: proper handling of catching exceptions by reference

2018-04-05 Thread John McCall via Phabricator via cfe-commits
rjmccall added a comment.

In https://reviews.llvm.org/D42092#1058841, @rsmith wrote:

> In https://reviews.llvm.org/D42092#1058772, @rjmccall wrote:
>
> > Issue #3 is tricky; it's arguably not okay to force a landing at a landing 
> > pad if we're not actually catching anything.
>
>
> I think the only way this is observable (at least within the bounds of 
> well-defined C++ code) is whether -- and how much -- the stack is unwound 
> before a call to `terminate()` in the case where an exception is not caught.
>
> [except.handle]p9 says: "If no matching handler is found, the function 
> std::terminate() is called; whether or not the stack is unwound before this 
> call to std::terminate() is implementation-defined (18.5.1)."
>  [except.terminate]p2 says: " In the situation where no matching handler is 
> found, it is implementation-defined whether or not the stack is unwound 
> before std::terminate() is called. In the situation where the search for a 
> handler (18.3) encounters the outermost block of a function with a 
> non-throwing exception specification (18.4), it is implementation-defined 
> whether the stack is unwound, unwound partially, or not unwound at all before 
> std::terminate() is called. In all other situations, the stack shall not be 
> unwound before std::terminate() is called."
>
> So I think you're right; this solution to issue #3 is non-conforming, because 
> it will result in the stack being partially unwound on the path to a call to 
> `std::terminate()` for an unhandled exception. Even if we changed the rule 
> for `terminate` to allow partial unwinding when no handler is found, this 
> patch would still give a QoI regression for that case (because the call to 
> the `terminate_handler` would happen after some unwinding had been performed).
>
> I'm not particularly interested in pushing this patch further if it can't 
> actually make catch-by-reference work properly. Let's drop this for now and 
> encourage interested parties to work on an alternative personality function.


Agreed.


Repository:
  rC Clang

https://reviews.llvm.org/D42092



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


Re: r328680 - [ObjC] Make C++ triviality type traits available to non-trivial C

2018-04-05 Thread John McCall via cfe-commits


> On Apr 5, 2018, at 3:54 PM, Akira Hatanaka  wrote:
> 
> 
>> On Apr 5, 2018, at 12:39 PM, John McCall > > wrote:
>> 
>> 
>> 
>>> On Apr 4, 2018, at 7:37 PM, Akira Hatanaka >> > wrote:
>>> 
>>> 
>>> 
 On Apr 4, 2018, at 4:24 PM, Akira Hatanaka via cfe-commits 
 mailto:cfe-commits@lists.llvm.org>> wrote:
 
> 
> On Apr 4, 2018, at 3:38 PM, Richard Smith  > wrote:
> 
> Hi Akira,
> 
> This change has broken the C++ versions of these type traits for classes 
> with volatile members. Such classes are required to claim to be trivial 
> per C++ DR 2094 
> (http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#2094 
> ) but 
> return false from isNonTrivialToPrimitiveCopy().
> 
 
 Oh that’s right. The function returns false when 
 isNonTrivialToPrimitiveCopy() returns PCK_VolatileTrivial. That is wrong.
 
> Also, exposing these __has_* traits more widely seems like a backwards 
> step to me: these traits are deprecated, near-useless, and we're trying 
> to remove them. No code should be using them under any circumstances; the 
> __is_* traits should be used instead.
> 
 
 The __is_* traits (is_trivially_copy_constructible, etc.) are templates 
 defined in libcxx, so it seems that we can’t use them when compiling in C 
 mode. Is it OK to add their definitions to TokenKinds.def as non-C++ 
 keywords?
 
>>> 
>>> Or perhaps redefine the six __has_* traits used here as non-C++ (KEYNOCXX 
>>> or ‘KEYC99 | KEYC11') keywords?
>> 
>> I think Richard is talking about e.g. the __is_trivially_destructible 
>> intrinsic type trait function rather than std::is_trivially_destructible.
>> 
>> Do we have a concrete need to expose these type traits to C?
>> 
> 
> No, no one has asked any of these type traits to be exposed to C yet. Do you 
> think we should just revert the patch and wait until someone asks for those 
> type traits to be available in C?

I think that would be fine.  Although it would be nice if we could save the 
part of the patch that makes the trait logic sensitive to the type queries 
instead of needing to include duplicated checks for __strong, __weak, and 
whatever other non-trivial C features we eventually add.

John.

> 
>> John.
>> 
>>> 
> On 27 March 2018 at 17:12, Akira Hatanaka via cfe-commits 
> mailto:cfe-commits@lists.llvm.org>> wrote:
> Author: ahatanak
> Date: Tue Mar 27 17:12:08 2018
> New Revision: 328680
> 
> URL: http://llvm.org/viewvc/llvm-project?rev=328680&view=rev 
> 
> Log:
> [ObjC] Make C++ triviality type traits available to non-trivial C
> structs.
> 
> r326307 and r327870 made changes that allowed using non-trivial C
> structs with fields qualified with __strong or __weak. This commit makes
> the following C++ triviality type traits available to non-trivial C
> structs:
> 
> __has_trivial_assign
> __has_trivial_move_assign
> __has_trivial_copy
> __has_trivial_move_constructor
> __has_trivial_constructor
> __has_trivial_destructor
> 
> rdar://problem/33599681 
> 
> Differential Revision: https://reviews.llvm.org/D44913 
> 
> 
> Added:
> cfe/trunk/test/SemaObjC/non-trivial-struct-traits.m
> Modified:
> cfe/trunk/include/clang/Basic/TokenKinds.def
> cfe/trunk/lib/Sema/SemaExprCXX.cpp
> 
> Modified: cfe/trunk/include/clang/Basic/TokenKinds.def
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/TokenKinds.def?rev=328680&r1=328679&r2=328680&view=diff
>  
> 
> ==
> --- cfe/trunk/include/clang/Basic/TokenKinds.def (original)
> +++ cfe/trunk/include/clang/Basic/TokenKinds.def Tue Mar 27 17:12:08 2018
> @@ -433,12 +433,12 @@ TYPE_TRAIT_1(__has_nothrow_assign, HasNo
>  TYPE_TRAIT_1(__has_nothrow_move_assign, HasNothrowMoveAssign, KEYCXX)
>  TYPE_TRAIT_1(__has_nothrow_copy, HasNothrowCopy, KEYCXX)
>  TYPE_TRAIT_1(__has_nothrow_constructor, HasNothrowConstructor, KEYCXX)
> -TYPE_TRAIT_1(__has_trivial_assign, HasTrivialAssign, KEYCXX)
> -TYPE_TRAIT_1(__has_trivial_move_assign, HasTrivialMoveAssign, KEYCXX)
> -TYPE_TRAIT_1(__has_trivial_copy, HasTrivialCopy, KEYCXX)
> -TYPE_TRAIT_1(__has_trivial_constructor, HasTrivialDefaultConstructor, 
> KEYCXX)
> -TYPE_TRAIT_1(__has_trivial_move_constructor, HasTrivialMoveConstructor, 
> KEYCXX)
> -TYPE_TRAIT_1(__has_trivial_destructor, HasTrivialDest

r329342 - PR36992: do not store beyond the dsize of a class object unless we know

2018-04-05 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Thu Apr  5 13:52:58 2018
New Revision: 329342

URL: http://llvm.org/viewvc/llvm-project?rev=329342&view=rev
Log:
PR36992: do not store beyond the dsize of a class object unless we know
the tail padding is not reused.

We track on the AggValueSlot (and through a couple of other
initialization actions) whether we're dealing with an object that might
share its tail padding with some other object, so that we can avoid
emitting stores into the tail padding if that's the case. We still
widen stores into tail padding when we can do so.

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

Added:
cfe/trunk/test/CodeGenCXX/tail-padding.cpp
Modified:
cfe/trunk/lib/CodeGen/CGAtomic.cpp
cfe/trunk/lib/CodeGen/CGBlocks.cpp
cfe/trunk/lib/CodeGen/CGCall.cpp
cfe/trunk/lib/CodeGen/CGClass.cpp
cfe/trunk/lib/CodeGen/CGDecl.cpp
cfe/trunk/lib/CodeGen/CGDeclCXX.cpp
cfe/trunk/lib/CodeGen/CGExpr.cpp
cfe/trunk/lib/CodeGen/CGExprAgg.cpp
cfe/trunk/lib/CodeGen/CGExprCXX.cpp
cfe/trunk/lib/CodeGen/CGObjC.cpp
cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp
cfe/trunk/lib/CodeGen/CGStmt.cpp
cfe/trunk/lib/CodeGen/CGValue.h
cfe/trunk/lib/CodeGen/CodeGenFunction.h
cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp

Modified: cfe/trunk/lib/CodeGen/CGAtomic.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGAtomic.cpp?rev=329342&r1=329341&r2=329342&view=diff
==
--- cfe/trunk/lib/CodeGen/CGAtomic.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGAtomic.cpp Thu Apr  5 13:52:58 2018
@@ -1513,7 +1513,8 @@ void AtomicInfo::emitCopyIntoMemory(RVal
 getAtomicType());
 bool IsVolatile = rvalue.isVolatileQualified() ||
   LVal.isVolatileQualified();
-CGF.EmitAggregateCopy(Dest, Src, getAtomicType(), IsVolatile);
+CGF.EmitAggregateCopy(Dest, Src, getAtomicType(),
+  AggValueSlot::DoesNotOverlap, IsVolatile);
 return;
   }
 
@@ -2008,6 +2009,7 @@ void CodeGenFunction::EmitAtomicInit(Exp
 AggValueSlot::IsNotDestructed,
 AggValueSlot::DoesNotNeedGCBarriers,
 AggValueSlot::IsNotAliased,
+AggValueSlot::DoesNotOverlap,
 Zeroed ? AggValueSlot::IsZeroed :
  AggValueSlot::IsNotZeroed);
 

Modified: cfe/trunk/lib/CodeGen/CGBlocks.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGBlocks.cpp?rev=329342&r1=329341&r2=329342&view=diff
==
--- cfe/trunk/lib/CodeGen/CGBlocks.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGBlocks.cpp Thu Apr  5 13:52:58 2018
@@ -929,7 +929,8 @@ llvm::Value *CodeGenFunction::EmitBlockL
 AggValueSlot::forAddr(blockField, Qualifiers(),
   AggValueSlot::IsDestructed,
   AggValueSlot::DoesNotNeedGCBarriers,
-  AggValueSlot::IsNotAliased);
+  AggValueSlot::IsNotAliased,
+  AggValueSlot::DoesNotOverlap);
 EmitAggExpr(copyExpr, Slot);
   } else {
 EmitSynthesizedCXXCopyCtor(blockField, src, copyExpr);

Modified: cfe/trunk/lib/CodeGen/CGCall.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGCall.cpp?rev=329342&r1=329341&r2=329342&view=diff
==
--- cfe/trunk/lib/CodeGen/CGCall.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGCall.cpp Thu Apr  5 13:52:58 2018
@@ -3018,7 +3018,8 @@ static AggValueSlot createPlaceholderSlo
Ty.getQualifiers(),
AggValueSlot::IsNotDestructed,
AggValueSlot::DoesNotNeedGCBarriers,
-   AggValueSlot::IsNotAliased);
+   AggValueSlot::IsNotAliased,
+   AggValueSlot::DoesNotOverlap);
 }
 
 void CodeGenFunction::EmitDelegateCallArg(CallArgList &args,
@@ -3486,7 +3487,8 @@ RValue CallArg::getRValue(CodeGenFunctio
   if (!HasLV)
 return RV;
   LValue Copy = CGF.MakeAddrLValue(CGF.CreateMemTemp(Ty), Ty);
-  CGF.EmitAggregateCopy(Copy, LV, Ty, LV.isVolatile());
+  CGF.EmitAggregateCopy(Copy, LV, Ty, AggValueSlot::DoesNotOverlap,
+LV.isVolatile());
   IsUsed = true;
   return RValue::getAggregate(Copy.getAddress());
 }
@@ -3500,7 +3502,8 @@ void CallArg::copyInto(CodeGenFunction &
   else {
 auto Addr = HasLV ? LV.getAddress() : RV.getAggregateAddress();
 LValue SrcLV = CGF.MakeAddrLValue(Addr, Ty);
-CGF.EmitAggregateCopy(Dst, SrcLV, Ty,
+// We assume that 

[PATCH] D45306: PR36992 don't overwrite virtual bases in tail padding

2018-04-05 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC329342: PR36992: do not store beyond the dsize of a class 
object unless we know (authored by rsmith, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D45306?vs=141205&id=141217#toc

Repository:
  rC Clang

https://reviews.llvm.org/D45306

Files:
  lib/CodeGen/CGAtomic.cpp
  lib/CodeGen/CGBlocks.cpp
  lib/CodeGen/CGCall.cpp
  lib/CodeGen/CGClass.cpp
  lib/CodeGen/CGDecl.cpp
  lib/CodeGen/CGDeclCXX.cpp
  lib/CodeGen/CGExpr.cpp
  lib/CodeGen/CGExprAgg.cpp
  lib/CodeGen/CGExprCXX.cpp
  lib/CodeGen/CGObjC.cpp
  lib/CodeGen/CGOpenMPRuntime.cpp
  lib/CodeGen/CGStmt.cpp
  lib/CodeGen/CGValue.h
  lib/CodeGen/CodeGenFunction.h
  lib/CodeGen/ItaniumCXXABI.cpp
  test/CodeGenCXX/tail-padding.cpp

Index: lib/CodeGen/CGDecl.cpp
===
--- lib/CodeGen/CGDecl.cpp
+++ lib/CodeGen/CGDecl.cpp
@@ -1416,17 +1416,17 @@
   }
 }
 
-/// Emit an expression as an initializer for a variable at the given
-/// location.  The expression is not necessarily the normal
-/// initializer for the variable, and the address is not necessarily
+/// Emit an expression as an initializer for an object (variable, field, etc.)
+/// at the given location.  The expression is not necessarily the normal
+/// initializer for the object, and the address is not necessarily
 /// its normal location.
 ///
 /// \param init the initializing expression
-/// \param var the variable to act as if we're initializing
+/// \param D the object to act as if we're initializing
 /// \param loc the address to initialize; its type is a pointer
-///   to the LLVM mapping of the variable's type
+///   to the LLVM mapping of the object's type
 /// \param alignment the alignment of the address
-/// \param capturedByInit true if the variable is a __block variable
+/// \param capturedByInit true if \p D is a __block variable
 ///   whose address is potentially changed by the initializer
 void CodeGenFunction::EmitExprAsInit(const Expr *init, const ValueDecl *D,
  LValue lvalue, bool capturedByInit) {
@@ -1454,11 +1454,17 @@
 if (type->isAtomicType()) {
   EmitAtomicInit(const_cast(init), lvalue);
 } else {
+  AggValueSlot::Overlap_t Overlap = AggValueSlot::MayOverlap;
+  if (isa(D))
+Overlap = AggValueSlot::DoesNotOverlap;
+  else if (auto *FD = dyn_cast(D))
+Overlap = overlapForFieldInit(FD);
   // TODO: how can we delay here if D is captured by its initializer?
   EmitAggExpr(init, AggValueSlot::forLValue(lvalue,
   AggValueSlot::IsDestructed,
  AggValueSlot::DoesNotNeedGCBarriers,
-  AggValueSlot::IsNotAliased));
+  AggValueSlot::IsNotAliased,
+  Overlap));
 }
 return;
   }
Index: lib/CodeGen/CGValue.h
===
--- lib/CodeGen/CGValue.h
+++ lib/CodeGen/CGValue.h
@@ -472,17 +472,25 @@
   /// evaluating an expression which constructs such an object.
   bool AliasedFlag : 1;
 
+  /// This is set to true if the tail padding of this slot might overlap 
+  /// another object that may have already been initialized (and whose
+  /// value must be preserved by this initialization). If so, we may only
+  /// store up to the dsize of the type. Otherwise we can widen stores to
+  /// the size of the type.
+  bool OverlapFlag : 1;
+
 public:
   enum IsAliased_t { IsNotAliased, IsAliased };
   enum IsDestructed_t { IsNotDestructed, IsDestructed };
   enum IsZeroed_t { IsNotZeroed, IsZeroed };
+  enum Overlap_t { DoesNotOverlap, MayOverlap };
   enum NeedsGCBarriers_t { DoesNotNeedGCBarriers, NeedsGCBarriers };
 
   /// ignored - Returns an aggregate value slot indicating that the
   /// aggregate value is being ignored.
   static AggValueSlot ignored() {
 return forAddr(Address::invalid(), Qualifiers(), IsNotDestructed,
-   DoesNotNeedGCBarriers, IsNotAliased);
+   DoesNotNeedGCBarriers, IsNotAliased, DoesNotOverlap);
   }
 
   /// forAddr - Make a slot for an aggregate value.
@@ -500,6 +508,7 @@
   IsDestructed_t isDestructed,
   NeedsGCBarriers_t needsGC,
   IsAliased_t isAliased,
+  Overlap_t mayOverlap,
   IsZeroed_t isZeroed = IsNotZeroed) {
 AggValueSlot AV;
 if (addr.isValid()) {
@@ -514,16 +523,18 @@
 AV.ObjCGCFlag = needsGC;
 AV.ZeroedFlag = isZeroed;
 AV.AliasedFlag = isAliased;
+AV.OverlapFlag = mayOverlap;
 return AV;
   }
 
   static AggValueSlot forLValue(const LValue &LV,
 IsDestructed_t isDestructed,

[PATCH] D45233: [Driver] Update GCC libraries detection logic for Gentoo.

2018-04-05 Thread Manoj Gupta via Phabricator via cfe-commits
manojgupta added a comment.

My understanding is that some of the tests are failing since we are scanning 
for Gentoo specific GCC installation first in both sysroot and "/". So, clang 
succeeds in find the libraries in "/usr/lib/gcc" even when sysroot argument is 
passed.
Previously, "/usr/lib/gcc" was not scanned when sysroot was passed.

Maybe, it is better to add /usr to list of paths to search instead of scanning 
in "/"?

Basically, Remove the newly added line 2245: SysRootPrefixes.push_back("");
and instead do Prefixes.push_back("/usr") ?


Repository:
  rC Clang

https://reviews.llvm.org/D45233



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


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

2018-04-05 Thread Eugene Zelenko via cfe-commits
Author: eugenezelenko
Date: Thu Apr  5 14:09:03 2018
New Revision: 329346

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

Modified:
cfe/trunk/include/clang/Sema/DeclSpec.h
cfe/trunk/include/clang/Sema/SemaFixItUtils.h
cfe/trunk/include/clang/Sema/SemaInternal.h
cfe/trunk/include/clang/Sema/Weak.h
cfe/trunk/lib/Sema/CodeCompleteConsumer.cpp
cfe/trunk/lib/Sema/DeclSpec.cpp
cfe/trunk/lib/Sema/IdentifierResolver.cpp
cfe/trunk/lib/Sema/SemaFixItUtils.cpp

Modified: cfe/trunk/include/clang/Sema/DeclSpec.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/DeclSpec.h?rev=329346&r1=329345&r2=329346&view=diff
==
--- cfe/trunk/include/clang/Sema/DeclSpec.h (original)
+++ cfe/trunk/include/clang/Sema/DeclSpec.h Thu Apr  5 14:09:03 2018
@@ -1,4 +1,4 @@
-//===--- DeclSpec.h - Parsed declaration specifiers -*- C++ 
-*-===//
+//===- DeclSpec.h - Parsed declaration specifiers ---*- C++ 
-*-===//
 //
 // The LLVM Compiler Infrastructure
 //
@@ -6,7 +6,7 @@
 // License. See LICENSE.TXT for details.
 //
 
//===--===//
-///
+//
 /// \file
 /// \brief This file defines the classes used to store parsed information about
 /// declaration-specifiers and declarators.
@@ -17,7 +17,7 @@
 /// declaration-specifiers  \  |   /
 ///declarators
 /// \endverbatim
-///
+//
 
//===--===//
 
 #ifndef LLVM_CLANG_SEMA_DECLSPEC_H
@@ -25,28 +25,39 @@
 
 #include "clang/AST/NestedNameSpecifier.h"
 #include "clang/Basic/ExceptionSpecificationType.h"
+#include "clang/Basic/LLVM.h"
 #include "clang/Basic/Lambda.h"
 #include "clang/Basic/OperatorKinds.h"
+#include "clang/Basic/SourceLocation.h"
 #include "clang/Basic/Specifiers.h"
 #include "clang/Lex/Token.h"
 #include "clang/Sema/AttributeList.h"
 #include "clang/Sema/Ownership.h"
+#include "llvm/ADT/ArrayRef.h"
 #include "llvm/ADT/SmallVector.h"
+#include "llvm/ADT/iterator_range.h"
 #include "llvm/Support/Compiler.h"
 #include "llvm/Support/ErrorHandling.h"
+#include 
+#include 
+#include 
 
 namespace clang {
-  class ASTContext;
-  class CXXRecordDecl;
-  class TypeLoc;
-  class LangOptions;
-  class IdentifierInfo;
-  class NamespaceAliasDecl;
-  class NamespaceDecl;
-  class ObjCDeclSpec;
-  class Sema;
-  class Declarator;
-  struct TemplateIdAnnotation;
+
+class ASTContext;
+class CXXRecordDecl;
+class Decl;
+class Declarator;
+class Expr;
+class IdentifierInfo;
+class LangOptions;
+class NamedDecl;
+class NamespaceAliasDecl;
+class NamespaceDecl;
+class ObjCDeclSpec;
+class Sema;
+struct TemplateIdAnnotation;
+class TypeLoc;
 
 /// \brief Represents a C++ nested-name-specifier or a global scope specifier.
 ///
@@ -187,11 +198,13 @@ public:
 
   /// No scope specifier.
   bool isEmpty() const { return !Range.isValid(); }
+
   /// A scope specifier is present, but may be valid or invalid.
   bool isNotEmpty() const { return !isEmpty(); }
 
   /// An error occurred during parsing of the scope specifier.
   bool isInvalid() const { return isNotEmpty() && getScopeRep() == nullptr; }
+
   /// A scope specifier is present, and it refers to a real scope.
   bool isValid() const { return isNotEmpty() && getScopeRep() != nullptr; }
 
@@ -242,14 +255,14 @@ public:
 
   // Import thread storage class specifier enumeration and constants.
   // These can be combined with SCS_extern and SCS_static.
-  typedef ThreadStorageClassSpecifier TSCS;
+  using TSCS = ThreadStorageClassSpecifier;
   static const TSCS TSCS_unspecified = clang::TSCS_unspecified;
   static const TSCS TSCS___thread = clang::TSCS___thread;
   static const TSCS TSCS_thread_local = clang::TSCS_thread_local;
   static const TSCS TSCS__Thread_local = clang::TSCS__Thread_local;
 
   // Import type specifier width enumeration and constants.
-  typedef TypeSpecifierWidth TSW;
+  using TSW = TypeSpecifierWidth;
   static const TSW TSW_unspecified = clang::TSW_unspecified;
   static const TSW TSW_short = clang::TSW_short;
   static const TSW TSW_long = clang::TSW_long;
@@ -262,13 +275,13 @@ public:
   };
 
   // Import type specifier sign enumeration and constants.
-  typedef TypeSpecifierSign TSS;
+  using TSS = TypeSpecifierSign;
   static const TSS TSS_unspecified = clang::TSS_unspecified;
   static const TSS TSS_signed = clang::TSS_signed;
   static const TSS TSS_unsigned = clang::TSS_unsigned;
 
   // Import type specifier type enumeration and constants.
-  typedef TypeSpecifierType TST;
+  using TST = TypeSpecifierType;
   static const TST TST_unspecified = clang::TST_unspecified;
   static const TST TST_void = clang::TST_void;
   static const TST TST_char = clang::TST_char;
@@ -381,11 +39

[PATCH] D45212: [HIP] Let CUDA toolchain support HIP language mode and amdgpu

2018-04-05 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl updated this revision to Diff 141221.
yaxunl marked an inline comment as done.
yaxunl edited the summary of this revision.
yaxunl added a comment.

Revised by reviewers' comments, including comments from previous review.


https://reviews.llvm.org/D45212

Files:
  include/clang/Basic/DiagnosticDriverKinds.td
  include/clang/Driver/Options.td
  include/clang/Driver/ToolChain.h
  include/clang/Driver/Types.def
  lib/Driver/Driver.cpp
  lib/Driver/SanitizerArgs.cpp
  lib/Driver/ToolChain.cpp
  lib/Driver/ToolChains/Clang.cpp
  lib/Driver/ToolChains/Cuda.cpp
  lib/Driver/ToolChains/Cuda.h
  lib/Driver/ToolChains/Gnu.cpp
  lib/Driver/Types.cpp
  lib/Frontend/CompilerInstance.cpp
  test/Driver/cuda-phases.cu

Index: test/Driver/cuda-phases.cu
===
--- test/Driver/cuda-phases.cu
+++ test/Driver/cuda-phases.cu
@@ -7,24 +7,29 @@
 // REQUIRES: clang-driver
 // REQUIRES: powerpc-registered-target
 // REQUIRES: nvptx-registered-target
-
+// REQUIRES: amdgpu-registered-target
 //
 // Test single gpu architecture with complete compilation.
 //
 // RUN: %clang -target powerpc64le-ibm-linux-gnu -ccc-print-phases --cuda-gpu-arch=sm_30 %s 2>&1 \
-// RUN: | FileCheck -check-prefix=BIN %s
-// BIN-DAG: [[P0:[0-9]+]]: input, "{{.*}}cuda-phases.cu", cuda, (host-cuda)
-// BIN-DAG: [[P1:[0-9]+]]: preprocessor, {[[P0]]}, cuda-cpp-output, (host-cuda)
+// RUN: | FileCheck -check-prefixes=BIN,BIN_NV %s
+// RUN: %clang -x hip -target powerpc64le-ibm-linux-gnu -ccc-print-phases --cuda-gpu-arch=gfx803 %s 2>&1 \
+// RUN: | FileCheck -check-prefixes=BIN,BIN_AMD %s
+// BIN_NV-DAG: [[P0:[0-9]+]]: input, "{{.*}}cuda-phases.cu", [[T:cuda]], (host-cuda)
+// BIN_AMD-DAG: [[P0:[0-9]+]]: input, "{{.*}}cuda-phases.cu", [[T:hip]], (host-cuda)
+// BIN-DAG: [[P1:[0-9]+]]: preprocessor, {[[P0]]}, [[T]]-cpp-output, (host-cuda)
 // BIN-DAG: [[P2:[0-9]+]]: compiler, {[[P1]]}, ir, (host-cuda)
-// BIN-DAG: [[P3:[0-9]+]]: input, "{{.*}}cuda-phases.cu", cuda, (device-cuda, sm_30)
-// BIN-DAG: [[P4:[0-9]+]]: preprocessor, {[[P3]]}, cuda-cpp-output, (device-cuda, sm_30)
-// BIN-DAG: [[P5:[0-9]+]]: compiler, {[[P4]]}, ir, (device-cuda, sm_30)
-// BIN-DAG: [[P6:[0-9]+]]: backend, {[[P5]]}, assembler, (device-cuda, sm_30)
-// BIN-DAG: [[P7:[0-9]+]]: assembler, {[[P6]]}, object, (device-cuda, sm_30)
-// BIN-DAG: [[P8:[0-9]+]]: offload, "device-cuda (nvptx64-nvidia-cuda:sm_30)" {[[P7]]}, object
-// BIN-DAG: [[P9:[0-9]+]]: offload, "device-cuda (nvptx64-nvidia-cuda:sm_30)" {[[P6]]}, assembler
+// BIN_NV-DAG: [[P3:[0-9]+]]: input, "{{.*}}cuda-phases.cu", [[T]], (device-cuda, [[ARCH:sm_30]])
+// BIN_AMD-DAG: [[P3:[0-9]+]]: input, "{{.*}}cuda-phases.cu", [[T]], (device-cuda, [[ARCH:gfx803]])
+// BIN-DAG: [[P4:[0-9]+]]: preprocessor, {[[P3]]}, [[T]]-cpp-output, (device-cuda, [[ARCH]])
+// BIN-DAG: [[P5:[0-9]+]]: compiler, {[[P4]]}, ir, (device-cuda, [[ARCH]])
+// BIN-DAG: [[P6:[0-9]+]]: backend, {[[P5]]}, assembler, (device-cuda, [[ARCH]])
+// BIN-DAG: [[P7:[0-9]+]]: assembler, {[[P6]]}, object, (device-cuda, [[ARCH]])
+// BIN_NV-DAG: [[P8:[0-9]+]]: offload, "device-cuda ([[TRIPLE:nvptx64-nvidia-cuda]]:[[ARCH]])" {[[P7]]}, object
+// BIN_AMD-DAG: [[P8:[0-9]+]]: offload, "device-cuda ([[TRIPLE:amdgcn-amd-amdhsa]]:[[ARCH]])" {[[P7]]}, object
+// BIN-DAG: [[P9:[0-9]+]]: offload, "device-cuda ([[TRIPLE]]:[[ARCH]])" {[[P6]]}, assembler
 // BIN-DAG: [[P10:[0-9]+]]: linker, {[[P8]], [[P9]]}, cuda-fatbin, (device-cuda)
-// BIN-DAG: [[P11:[0-9]+]]: offload, "host-cuda (powerpc64le-ibm-linux-gnu)" {[[P2]]}, "device-cuda (nvptx64-nvidia-cuda)" {[[P10]]}, ir
+// BIN-DAG: [[P11:[0-9]+]]: offload, "host-cuda (powerpc64le-ibm-linux-gnu)" {[[P2]]}, "device-cuda ([[TRIPLE]])" {[[P10]]}, ir
 // BIN-DAG: [[P12:[0-9]+]]: backend, {[[P11]]}, assembler, (host-cuda)
 // BIN-DAG: [[P13:[0-9]+]]: assembler, {[[P12]]}, object, (host-cuda)
 // BIN-DAG: [[P14:[0-9]+]]: linker, {[[P13]]}, image, (host-cuda)
@@ -34,40 +39,44 @@
 //
 // RUN: %clang -target powerpc64le-ibm-linux-gnu -ccc-print-phases --cuda-gpu-arch=sm_30 %s -S 2>&1 \
 // RUN: | FileCheck -check-prefix=ASM %s
-// ASM-DAG: [[P0:[0-9]+]]: input, "{{.*}}cuda-phases.cu", cuda, (device-cuda, sm_30)
-// ASM-DAG: [[P1:[0-9]+]]: preprocessor, {[[P0]]}, cuda-cpp-output, (device-cuda, sm_30)
-// ASM-DAG: [[P2:[0-9]+]]: compiler, {[[P1]]}, ir, (device-cuda, sm_30)
-// ASM-DAG: [[P3:[0-9]+]]: backend, {[[P2]]}, assembler, (device-cuda, sm_30)
-// ASM-DAG: [[P4:[0-9]+]]: offload, "device-cuda (nvptx64-nvidia-cuda:sm_30)" {[[P3]]}, assembler
-// ASM-DAG: [[P5:[0-9]+]]: input, "{{.*}}cuda-phases.cu", cuda, (host-cuda)
-// ASM-DAG: [[P6:[0-9]+]]: preprocessor, {[[P5]]}, cuda-cpp-output, (host-cuda)
+// RUN: %clang -x hip -target powerpc64le-ibm-linux-gnu -ccc-print-phases --cuda-gpu-arch=gfx803 %s -S 2>&1 \
+// RUN: | FileCheck -check-prefix=ASM %s
+// ASM-DAG: [[P0:[0-9]+]]: input, "{{.*}}cuda-phases.cu", [[T:cuda|hip]], (device-cuda, [[ARCH:sm_30|gfx803]])
+// ASM-DAG: [[P1:[0-9]+

[PATCH] D45233: [Driver] Update GCC libraries detection logic for Gentoo.

2018-04-05 Thread Michał Górny via Phabricator via cfe-commits
mgorny added a comment.

Ok, that's a problem. I think we really ought to consider all possibilites of 
sysroot first, and either do not fall back to main system at all or do that 
only if sysroot doesn't have any install at all. Basically, it is important 
that we don't break non-Gentoo sysroots, even when running on top of Gentoo.

I don't really understand what you mean with the prefixes stuff but it doesn't 
sound like it's going to solve the problem.


Repository:
  rC Clang

https://reviews.llvm.org/D45233



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


[PATCH] D45335: [analyzer] RetainCount: Accept more "safe" CFRetain wrappers.

2018-04-05 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ created this revision.
NoQ added reviewers: dcoughlin, george.karpenkov.
Herald added subscribers: cfe-commits, a.sidorin, JDevlieghere, szepet, 
xazax.hun.

https://reviews.llvm.org/D38877 added support for the misplaced 
`CF_RETURNS_RETAINED` annotation on `CFRetain()` wrappers. It works by trusting 
the function's name (seeing if it confirms to the CoreFoundation naming 
convention) rather than the annotation.

There are more false positives caused by users using a different naming 
convention, namely starting the function name with "retain" or "release" rather 
than suffixing it with "retain" or "release" respectively.

Because this isn't according to the naming convention, these functions are 
usually inlined and the annotation is therefore ignored, which is correct. But 
sometimes we run out of inlining stack depth and the function is evaluated 
conservatively and then the annotation is trusted.

Add support for the "alternative" naming convention and test the situation when 
we're running out of inlining stack depth.


Repository:
  rC Clang

https://reviews.llvm.org/D45335

Files:
  lib/StaticAnalyzer/Checkers/RetainCountChecker.cpp
  test/Analysis/retain-release-safe.c


Index: test/Analysis/retain-release-safe.c
===
--- test/Analysis/retain-release-safe.c
+++ test/Analysis/retain-release-safe.c
@@ -1,4 +1,5 @@
 // RUN: %clang_analyze_cc1 
-analyzer-checker=core,osx.coreFoundation.CFRetainRelease,osx.cocoa.RetainCount 
-verify %s
+// RUN: %clang_analyze_cc1 
-analyzer-checker=core,osx.coreFoundation.CFRetainRelease,osx.cocoa.RetainCount 
-analyzer-inline-max-stack-depth=0 -verify %s
 
 #pragma clang arc_cf_code_audited begin
 typedef const void * CFTypeRef;
@@ -35,6 +36,19 @@
 CFRelease(cf); // no-warning (when inlined)
 }
 
+// The same thing, just with a different naming style.
+CFTypeRef retainCFType(CFTypeRef cf) CF_RETURNS_RETAINED {
+  if (cf) {
+return CFRetain(cf);
+  }
+  return cf;
+}
+
+void releaseCFType(CFTypeRef CF_CONSUMED cf) {
+  if (cf)
+CFRelease(cf); // no-warning (when inlined)
+}
+
 void escape(CFTypeRef cf);
 
 void makeSureTestsWork() {
@@ -70,3 +84,10 @@
   SafeCFRelease(cf);
   SafeCFRelease(cf); // no-warning after inlining this.
 }
+
+void testTheOtherNamingConvention(CFTypeRef cf) {
+  retainCFType(cf);
+  retainCFType(cf);
+  releaseCFType(cf);
+  releaseCFType(cf); // no-warning
+}
Index: lib/StaticAnalyzer/Checkers/RetainCountChecker.cpp
===
--- lib/StaticAnalyzer/Checkers/RetainCountChecker.cpp
+++ lib/StaticAnalyzer/Checkers/RetainCountChecker.cpp
@@ -883,21 +883,22 @@
 
//===--===//
 
 static bool isRetain(const FunctionDecl *FD, StringRef FName) {
-  return FName.endswith("Retain");
+  return FName.startswith_lower("retain") || FName.endswith_lower("retain");
 }
 
 static bool isRelease(const FunctionDecl *FD, StringRef FName) {
-  return FName.endswith("Release");
+  return FName.startswith_lower("release") || FName.endswith_lower("release");
 }
 
 static bool isAutorelease(const FunctionDecl *FD, StringRef FName) {
-  return FName.endswith("Autorelease");
+  return FName.startswith_lower("autorelease") ||
+ FName.endswith_lower("autorelease");
 }
 
 static bool isMakeCollectable(const FunctionDecl *FD, StringRef FName) {
   // FIXME: Remove FunctionDecl parameter.
   // FIXME: Is it really okay if MakeCollectable isn't a suffix?
-  return FName.find("MakeCollectable") != StringRef::npos;
+  return FName.find_lower("MakeCollectable") != StringRef::npos;
 }
 
 static ArgEffect getStopTrackingHardEquivalent(ArgEffect E) {


Index: test/Analysis/retain-release-safe.c
===
--- test/Analysis/retain-release-safe.c
+++ test/Analysis/retain-release-safe.c
@@ -1,4 +1,5 @@
 // RUN: %clang_analyze_cc1 -analyzer-checker=core,osx.coreFoundation.CFRetainRelease,osx.cocoa.RetainCount -verify %s
+// RUN: %clang_analyze_cc1 -analyzer-checker=core,osx.coreFoundation.CFRetainRelease,osx.cocoa.RetainCount -analyzer-inline-max-stack-depth=0 -verify %s
 
 #pragma clang arc_cf_code_audited begin
 typedef const void * CFTypeRef;
@@ -35,6 +36,19 @@
 CFRelease(cf); // no-warning (when inlined)
 }
 
+// The same thing, just with a different naming style.
+CFTypeRef retainCFType(CFTypeRef cf) CF_RETURNS_RETAINED {
+  if (cf) {
+return CFRetain(cf);
+  }
+  return cf;
+}
+
+void releaseCFType(CFTypeRef CF_CONSUMED cf) {
+  if (cf)
+CFRelease(cf); // no-warning (when inlined)
+}
+
 void escape(CFTypeRef cf);
 
 void makeSureTestsWork() {
@@ -70,3 +84,10 @@
   SafeCFRelease(cf);
   SafeCFRelease(cf); // no-warning after inlining this.
 }
+
+void testTheOtherNamingConvention(CFTypeRef cf) {
+  retainCFType(cf);
+  retainCFType(cf);
+  releaseCFType(cf);
+  releaseCFType(cf); // no-warning
+}
Index: lib/

[PATCH] D44617: [Transforms] Keep TBAA tags in SimplifyCFG transformations

2018-04-05 Thread Danil Malyshev via Phabricator via cfe-commits
DanilM added a comment.

ping


Repository:
  rC Clang

https://reviews.llvm.org/D44617



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


[PATCH] D44616: Update existed CodeGen TBAA tests

2018-04-05 Thread Danil Malyshev via Phabricator via cfe-commits
DanilM added a comment.

ping


Repository:
  rC Clang

https://reviews.llvm.org/D44616



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


Re: r329300 - Disable -fmerge-all-constants as default.

2018-04-05 Thread Galina Kistanova via cfe-commits
Hello Manoj,

Looks like this commit broke tests at couple of our builders:
r329300
http://lab.llvm.org:8011/builders/clang-with-thin-lto-ubuntu/builds/9600

Few tests failed:
. . .
Failing Tests (7):
LLVM :: CodeGen/Mips/Fast-ISel/fastalloca.ll
LLVM :: CodeGen/Mips/Fast-ISel/fastcc-miss.ll
LLVM :: CodeGen/Mips/Fast-ISel/memtest1.ll
LLVM :: CodeGen/Mips/Fast-ISel/mul1.ll
LLVM :: CodeGen/Mips/Fast-ISel/sel1.ll
LLVM :: CodeGen/Mips/call-optimization.ll
LLVM :: DebugInfo/Mips/delay-slot.ll

Previous revision:
http://lab.llvm.org:8011/builders/clang-with-thin-lto-ubuntu/builds/9602

Also another builder is affected:
http://lab.llvm.org:8011/builders/clang-with-lto-ubuntu

Both builders were red and did not send notifications.

Please have a look?

Thanks

Galina

On Thu, Apr 5, 2018 at 8:29 AM, Manoj Gupta via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: manojgupta
> Date: Thu Apr  5 08:29:52 2018
> New Revision: 329300
>
> URL: http://llvm.org/viewvc/llvm-project?rev=329300&view=rev
> Log:
> Disable -fmerge-all-constants as default.
>
> Summary:
> "-fmerge-all-constants" is a non-conforming optimization and should not
> be the default. It is also causing miscompiles when building Linux
> Kernel (https://lkml.org/lkml/2018/3/20/872).
>
> Fixes PR18538.
>
> Reviewers: rjmccall, rsmith, chandlerc
>
> Reviewed By: rsmith, chandlerc
>
> Subscribers: srhines, cfe-commits
>
> Differential Revision: https://reviews.llvm.org/D45289
>
> Modified:
> cfe/trunk/include/clang/Driver/Options.td
> cfe/trunk/lib/AST/ExprConstant.cpp
> cfe/trunk/lib/Driver/ToolChains/Clang.cpp
> cfe/trunk/lib/Frontend/CompilerInvocation.cpp
> cfe/trunk/test/CodeGen/array-init.c
> cfe/trunk/test/CodeGen/decl.c
> cfe/trunk/test/CodeGenCXX/const-init-cxx11.cpp
> cfe/trunk/test/CodeGenCXX/cxx0x-initializer-references.cpp
> cfe/trunk/test/CodeGenCXX/cxx0x-initializer-stdinitializerlist.cpp
> cfe/trunk/test/CodeGenObjCXX/arc-cxx11-init-list.mm
> cfe/trunk/test/Driver/clang_f_opts.c
>
> Modified: cfe/trunk/include/clang/Driver/Options.td
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/
> clang/Driver/Options.td?rev=329300&r1=329299&r2=329300&view=diff
> 
> ==
> --- cfe/trunk/include/clang/Driver/Options.td (original)
> +++ cfe/trunk/include/clang/Driver/Options.td Thu Apr  5 08:29:52 2018
> @@ -1133,7 +1133,8 @@ def fthinlto_index_EQ : Joined<["-"], "f
>HelpText<"Perform ThinLTO importing using provided function summary
> index">;
>  def fmacro_backtrace_limit_EQ : Joined<["-"], "fmacro-backtrace-limit=">,
>  Group, Flags<[DriverOption,
> CoreOption]>;
> -def fmerge_all_constants : Flag<["-"], "fmerge-all-constants">,
> Group;
> +def fmerge_all_constants : Flag<["-"], "fmerge-all-constants">,
> Group,
> +  Flags<[CC1Option]>, HelpText<"Allow merging of constants">;
>  def fmessage_length_EQ : Joined<["-"], "fmessage-length=">,
> Group;
>  def fms_extensions : Flag<["-"], "fms-extensions">, Group,
> Flags<[CC1Option, CoreOption]>,
>HelpText<"Accept some non-standard constructs supported by the
> Microsoft compiler">;
> @@ -1282,7 +1283,7 @@ def fveclib : Joined<["-"], "fveclib=">,
>  def fno_lax_vector_conversions : Flag<["-"],
> "fno-lax-vector-conversions">, Group,
>HelpText<"Disallow implicit conversions between vectors with a
> different number of elements or different element types">,
> Flags<[CC1Option]>;
>  def fno_merge_all_constants : Flag<["-"], "fno-merge-all-constants">,
> Group,
> -Flags<[CC1Option]>, HelpText<"Disallow merging of constants">;
> +  HelpText<"Disallow merging of constants">;
>  def fno_modules : Flag <["-"], "fno-modules">, Group,
>Flags<[DriverOption]>;
>  def fno_implicit_module_maps : Flag <["-"], "fno-implicit-module-maps">,
> Group,
>
> Modified: cfe/trunk/lib/AST/ExprConstant.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/
> ExprConstant.cpp?rev=329300&r1=329299&r2=329300&view=diff
> 
> ==
> --- cfe/trunk/lib/AST/ExprConstant.cpp (original)
> +++ cfe/trunk/lib/AST/ExprConstant.cpp Thu Apr  5 08:29:52 2018
> @@ -8596,9 +8596,6 @@ bool IntExprEvaluator::VisitBinaryOperat
>  (LHSValue.Base && isZeroSized(RHSValue)))
>return Error(E);
>  // Pointers with different bases cannot represent the same object.
> -// (Note that clang defaults to -fmerge-all-constants, which can
> -// lead to inconsistent results for comparisons involving the
> address
> -// of a constant; this generally doesn't matter in practice.)
>  return Success(E->getOpcode() == BO_NE, E);
>}
>
>
> Modified: cfe/trunk/lib/Driver/ToolChains/Clang.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/
> ToolChains/Clang.cpp?rev=329300&r1=329299&r2=329300&view

  1   2   >