[PATCH] D43033: [WinEH] Put funclet bundles on inline asm calls

2018-02-07 Thread David Majnemer via Phabricator via cfe-commits
majnemer accepted this revision.
majnemer added a comment.
This revision is now accepted and ready to land.

LGTM


https://reviews.llvm.org/D43033



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


[clang-tools-extra] r324575 - Resubmit "[clangd] The new threading implementation"

2018-02-07 Thread Ilya Biryukov via cfe-commits
Author: ibiryukov
Date: Wed Feb  7 23:37:35 2018
New Revision: 324575

URL: http://llvm.org/viewvc/llvm-project?rev=324575=rev
Log:
Resubmit "[clangd] The new threading implementation"

Initially submitted as r324356 and reverted in r324386.

This change additionally contains a fix to crashes of the buildbots.
The source of the crash was undefined behaviour caused by
std::future<> whose std::promise<> was destroyed without calling
set_value().

Added:
clang-tools-extra/trunk/unittests/clangd/ThreadingTests.cpp
Removed:
clang-tools-extra/trunk/clangd/ClangdUnitStore.cpp
clang-tools-extra/trunk/clangd/ClangdUnitStore.h
Modified:
clang-tools-extra/trunk/clangd/CMakeLists.txt
clang-tools-extra/trunk/clangd/ClangdServer.cpp
clang-tools-extra/trunk/clangd/ClangdServer.h
clang-tools-extra/trunk/clangd/ClangdUnit.h
clang-tools-extra/trunk/clangd/TUScheduler.cpp
clang-tools-extra/trunk/clangd/TUScheduler.h
clang-tools-extra/trunk/clangd/Threading.cpp
clang-tools-extra/trunk/clangd/Threading.h
clang-tools-extra/trunk/unittests/clangd/CMakeLists.txt
clang-tools-extra/trunk/unittests/clangd/ClangdTests.cpp
clang-tools-extra/trunk/unittests/clangd/TUSchedulerTests.cpp

Modified: clang-tools-extra/trunk/clangd/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/CMakeLists.txt?rev=324575=324574=324575=diff
==
--- clang-tools-extra/trunk/clangd/CMakeLists.txt (original)
+++ clang-tools-extra/trunk/clangd/CMakeLists.txt Wed Feb  7 23:37:35 2018
@@ -6,7 +6,6 @@ add_clang_library(clangDaemon
   ClangdLSPServer.cpp
   ClangdServer.cpp
   ClangdUnit.cpp
-  ClangdUnitStore.cpp
   CodeComplete.cpp
   CodeCompletionStrings.cpp
   CompileArgsCache.cpp

Modified: clang-tools-extra/trunk/clangd/ClangdServer.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/ClangdServer.cpp?rev=324575=324574=324575=diff
==
--- clang-tools-extra/trunk/clangd/ClangdServer.cpp (original)
+++ clang-tools-extra/trunk/clangd/ClangdServer.cpp Wed Feb  7 23:37:35 2018
@@ -146,23 +146,10 @@ std::future ClangdServer::addDocum
  std::move(TaggedFS));
 }
 
-std::future ClangdServer::removeDocument(PathRef File) {
+void ClangdServer::removeDocument(PathRef File) {
   DraftMgr.removeDraft(File);
   CompileArgs.invalidate(File);
-
-  std::promise DonePromise;
-  std::future DoneFuture = DonePromise.get_future();
-
-  auto Callback = BindWithForward(
-  [](std::promise DonePromise, llvm::Error Err) {
-if (Err)
-  ignoreError(std::move(Err));
-DonePromise.set_value();
-  },
-  std::move(DonePromise));
-
-  WorkScheduler.remove(File, std::move(Callback));
-  return DoneFuture;
+  WorkScheduler.remove(File);
 }
 
 std::future ClangdServer::forceReparse(PathRef File) {

Modified: clang-tools-extra/trunk/clangd/ClangdServer.h
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/ClangdServer.h?rev=324575=324574=324575=diff
==
--- clang-tools-extra/trunk/clangd/ClangdServer.h (original)
+++ clang-tools-extra/trunk/clangd/ClangdServer.h Wed Feb  7 23:37:35 2018
@@ -11,7 +11,6 @@
 #define LLVM_CLANG_TOOLS_EXTRA_CLANGD_CLANGDSERVER_H
 
 #include "ClangdUnit.h"
-#include "ClangdUnitStore.h"
 #include "CodeComplete.h"
 #include "CompileArgsCache.h"
 #include "DraftStore.h"
@@ -158,11 +157,7 @@ public:
 
   /// Remove \p File from list of tracked files, schedule a request to free
   /// resources associated with it.
-  /// \return A future that will become ready when the file is removed and all
-  /// associated resources are freed.
-  /// FIXME: don't return futures here, LSP does not require a response for 
this
-  /// request.
-  std::future removeDocument(PathRef File);
+  void removeDocument(PathRef File);
 
   /// Force \p File to be reparsed using the latest contents.
   /// Will also check if CompileCommand, provided by GlobalCompilationDatabase

Modified: clang-tools-extra/trunk/clangd/ClangdUnit.h
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/ClangdUnit.h?rev=324575=324574=324575=diff
==
--- clang-tools-extra/trunk/clangd/ClangdUnit.h (original)
+++ clang-tools-extra/trunk/clangd/ClangdUnit.h Wed Feb  7 23:37:35 2018
@@ -151,6 +151,8 @@ using ASTParsedCallback = std::function<
 
 /// Manages resources, required by clangd. Allows to rebuild file with new
 /// contents, and provides AST and Preamble for it.
+/// NOTE: Threading-related bits of CppFile are now deprecated and will be
+/// removed soon.
 class CppFile : public std::enable_shared_from_this {
 public:
   // We only allow to create CppFile as shared_ptr, because a future returned 

[PATCH] D41597: CMAKE: disable -mbig-obj for mingw clang asm

2018-02-07 Thread Martell Malone via Phabricator via cfe-commits
martell added a comment.

Updated to just ignore the flag just like how clang-cl does for /bigobj


Repository:
  rC Clang

https://reviews.llvm.org/D41597



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


[PATCH] D41597: CMAKE: disable -mbig-obj for mingw clang asm

2018-02-07 Thread Martell Malone via Phabricator via cfe-commits
martell updated this revision to Diff 133374.
Herald added a subscriber: cfe-commits.

Repository:
  rC Clang

https://reviews.llvm.org/D41597

Files:
  include/clang/Driver/Options.td


Index: include/clang/Driver/Options.td
===
--- include/clang/Driver/Options.td
+++ include/clang/Driver/Options.td
@@ -1768,6 +1768,7 @@
 def masm_EQ : Joined<["-"], "masm=">, Group, Flags<[DriverOption]>;
 def mcmodel_EQ : Joined<["-"], "mcmodel=">, Group;
 def mimplicit_it_EQ : Joined<["-"], "mimplicit-it=">, Group;
+def mbig_obj : Flag<["-"], "mbig-obj">, Group;
 def mdefault_build_attributes : Joined<["-"], "mdefault-build-attributes">, 
Group;
 def mno_default_build_attributes : Joined<["-"], 
"mno-default-build-attributes">, Group;
 def mconstant_cfstrings : Flag<["-"], "mconstant-cfstrings">, 
Group;


Index: include/clang/Driver/Options.td
===
--- include/clang/Driver/Options.td
+++ include/clang/Driver/Options.td
@@ -1768,6 +1768,7 @@
 def masm_EQ : Joined<["-"], "masm=">, Group, Flags<[DriverOption]>;
 def mcmodel_EQ : Joined<["-"], "mcmodel=">, Group;
 def mimplicit_it_EQ : Joined<["-"], "mimplicit-it=">, Group;
+def mbig_obj : Flag<["-"], "mbig-obj">, Group;
 def mdefault_build_attributes : Joined<["-"], "mdefault-build-attributes">, Group;
 def mno_default_build_attributes : Joined<["-"], "mno-default-build-attributes">, Group;
 def mconstant_cfstrings : Flag<["-"], "mconstant-cfstrings">, Group;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[libcxx] r324573 - Temporarily comment out deduction guide tests while I figure out what to do with old bots

2018-02-07 Thread Marshall Clow via cfe-commits
Author: marshall
Date: Wed Feb  7 23:20:45 2018
New Revision: 324573

URL: http://llvm.org/viewvc/llvm-project?rev=324573=rev
Log:
Temporarily comment out deduction guide tests while I figure out what to do 
with old bots

Modified:
libcxx/trunk/test/std/strings/basic.string/string.cons/iter_alloc.fail.cpp
libcxx/trunk/test/std/strings/basic.string/string.cons/iter_alloc.pass.cpp

Modified: 
libcxx/trunk/test/std/strings/basic.string/string.cons/iter_alloc.fail.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/strings/basic.string/string.cons/iter_alloc.fail.cpp?rev=324573=324572=324573=diff
==
--- libcxx/trunk/test/std/strings/basic.string/string.cons/iter_alloc.fail.cpp 
(original)
+++ libcxx/trunk/test/std/strings/basic.string/string.cons/iter_alloc.fail.cpp 
Wed Feb  7 23:20:45 2018
@@ -9,6 +9,7 @@
 
 // 
 // UNSUPPORTED: c++98, c++03, c++11, c++14
+// XFAIL: c++17
 
 // template::value_type>>

Modified: 
libcxx/trunk/test/std/strings/basic.string/string.cons/iter_alloc.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/strings/basic.string/string.cons/iter_alloc.pass.cpp?rev=324573=324572=324573=diff
==
--- libcxx/trunk/test/std/strings/basic.string/string.cons/iter_alloc.pass.cpp 
(original)
+++ libcxx/trunk/test/std/strings/basic.string/string.cons/iter_alloc.pass.cpp 
Wed Feb  7 23:20:45 2018
@@ -129,6 +129,7 @@ int main()
 }
 #endif
 
+#if 0
 //  Test deduction guides
 #if TEST_STD_VER > 14
 {
@@ -172,4 +173,5 @@ int main()
 assert(s1.compare(0, s1.size(), s, s1.size()) == 0);
 }
 #endif
+#endif
 }


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


[PATCH] D42614: AST: support ObjC lifetime qualifiers in MS ABI

2018-02-07 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.

In https://reviews.llvm.org/D42614#1001279, @compnerd wrote:

> @rjmccall, I've updated the approach and no longer abuse the existing 
> decoration styles.  This uses a custom namespace with artificial types to 
> differentiate the types.  I've also ensured that the parameter types do not 
> encode the type information.


Alright, thanks, LGTM.


Repository:
  rC Clang

https://reviews.llvm.org/D42614



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


[libcxx] r324569 - Implement deduction guide for basic_string as described in P0433

2018-02-07 Thread Marshall Clow via cfe-commits
Author: marshall
Date: Wed Feb  7 22:34:03 2018
New Revision: 324569

URL: http://llvm.org/viewvc/llvm-project?rev=324569=rev
Log:
Implement deduction guide for basic_string as described in P0433

Added:
libcxx/trunk/test/std/strings/basic.string/string.cons/iter_alloc.fail.cpp
Modified:
libcxx/trunk/include/string
libcxx/trunk/test/std/strings/basic.string/string.cons/iter_alloc.pass.cpp
libcxx/trunk/www/cxx1z_status.html

Modified: libcxx/trunk/include/string
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/string?rev=324569=324568=324569=diff
==
--- libcxx/trunk/include/string (original)
+++ libcxx/trunk/include/string Wed Feb  7 22:34:03 2018
@@ -311,6 +311,13 @@ public:
 bool __invariants() const;
 };
 
+template::value_type>>
+basic_string(InputIterator, InputIterator, Allocator = Allocator())
+   -> basic_string::value_type,
+  char_traits::value_type>,
+  Allocator>;   // C++17
+
 template
 basic_string
 operator+(const basic_string& lhs,
@@ -1485,6 +1492,18 @@ private:
 friend basic_string operator+<>(const basic_string&, value_type);
 };
 
+#ifndef _LIBCPP_HAS_NO_DEDUCTION_GUIDES
+template::value_type,
+ class _Allocator = allocator<_CharT>,
+ class = typename 
enable_if<__is_input_iterator<_InputIterator>::value, void>::type,
+ class = typename enable_if<__is_allocator<_Allocator>::value, 
void>::type
+ >
+basic_string(_InputIterator, _InputIterator, _Allocator = _Allocator())
+  -> basic_string<_CharT, char_traits<_CharT>, _Allocator>;
+#endif
+
+  
 template 
 inline _LIBCPP_INLINE_VISIBILITY
 void

Added: 
libcxx/trunk/test/std/strings/basic.string/string.cons/iter_alloc.fail.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/strings/basic.string/string.cons/iter_alloc.fail.cpp?rev=324569=auto
==
--- libcxx/trunk/test/std/strings/basic.string/string.cons/iter_alloc.fail.cpp 
(added)
+++ libcxx/trunk/test/std/strings/basic.string/string.cons/iter_alloc.fail.cpp 
Wed Feb  7 22:34:03 2018
@@ -0,0 +1,54 @@
+//===--===//
+//
+// 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, c++11, c++14
+
+// template::value_type>>
+//  basic_string(InputIterator, InputIterator, Allocator = Allocator())
+//-> basic_string::value_type,
+// char_traits::value_type>,
+// Allocator>;
+//
+//  The deduction guide shall not participate in overload resolution if 
InputIterator
+//  is a type that does not qualify as an input iterator, or if Allocator is a 
type
+//  that does not qualify as an allocator.
+
+
+#include 
+#include 
+#include 
+#include 
+
+#include "test_macros.h"
+
+class NotAnItertor {};
+
+template 
+struct NotAnAllocator { typedef T value_type; };
+
+int main()
+{
+{ // Not an iterator at all
+std::basic_string s1{NotAnItertor{}, NotAnItertor{}, 
std::allocator{}}; // expected-error {{no viable constructor or deduction 
guide for deduction of template arguments of 'basic_string'}}
+}
+{ // Not an input iterator
+const char16_t* s = u"12345678901234";
+std::basic_string s0;
+std::basic_string s1{std::back_insert_iterator(s0), //  expected-error 
{{no viable constructor or deduction guide for deduction of template arguments 
of 'basic_string'}}
+ std::back_insert_iterator(s0),
+ std::allocator{}};
+}
+{ // Not an allocator
+const wchar_t* s = L"12345678901234";
+std::basic_string s1{s, s+10, NotAnAllocator{}}; // 
expected-error {{no viable constructor or deduction guide for deduction of 
template arguments of 'basic_string'}}
+}
+
+}

Modified: 
libcxx/trunk/test/std/strings/basic.string/string.cons/iter_alloc.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/strings/basic.string/string.cons/iter_alloc.pass.cpp?rev=324569=324568=324569=diff
==
--- libcxx/trunk/test/std/strings/basic.string/string.cons/iter_alloc.pass.cpp 
(original)
+++ libcxx/trunk/test/std/strings/basic.string/string.cons/iter_alloc.pass.cpp 
Wed Feb  7 22:34:03 2018
@@ -13,6 +13,18 @@
 //   basic_string(InputIterator begin, InputIterator end,
 //   const Allocator& a = Allocator());
 
+// template::value_type>>
+//  basic_string(InputIterator, InputIterator, Allocator = Allocator())
+//-> basic_string::value_type,
+// 

[libcxx] r324566 - Improve a test. NFC

2018-02-07 Thread Marshall Clow via cfe-commits
Author: marshall
Date: Wed Feb  7 21:47:40 2018
New Revision: 324566

URL: http://llvm.org/viewvc/llvm-project?rev=324566=rev
Log:
Improve a test. NFC

Modified:
libcxx/trunk/test/libcxx/memory/is_allocator.pass.cpp

Modified: libcxx/trunk/test/libcxx/memory/is_allocator.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/libcxx/memory/is_allocator.pass.cpp?rev=324566=324565=324566=diff
==
--- libcxx/trunk/test/libcxx/memory/is_allocator.pass.cpp (original)
+++ libcxx/trunk/test/libcxx/memory/is_allocator.pass.cpp Wed Feb  7 21:47:40 
2018
@@ -26,6 +26,7 @@
 template 
 void test_allocators()
 {
+   static_assert(!std::__is_allocator::value, "" );
static_assert( std::__is_allocator::value, "" );
static_assert( std::__is_allocator::value, "" );
static_assert( std::__is_allocator::value, "" );


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


[PATCH] D35894: [clangd] Code hover for Clangd

2018-02-07 Thread Simon Marchi via Phabricator via cfe-commits
simark updated this revision to Diff 133367.
simark added a comment.
Herald added subscribers: ioeric, jkorous-apple.

New version

Here's a new version of the patch, quite reworked.  I scaled down the scope a
little bit to make it simpler (see commit log).  We'll add more features later
on.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D35894

Files:
  clangd/ClangdLSPServer.cpp
  clangd/ClangdLSPServer.h
  clangd/ClangdServer.cpp
  clangd/ClangdServer.h
  clangd/Protocol.cpp
  clangd/Protocol.h
  clangd/ProtocolHandlers.cpp
  clangd/ProtocolHandlers.h
  clangd/XRefs.cpp
  clangd/XRefs.h
  test/clangd/hover.test
  test/clangd/initialize-params-invalid.test
  test/clangd/initialize-params.test
  unittests/clangd/XRefsTests.cpp

Index: unittests/clangd/XRefsTests.cpp
===
--- unittests/clangd/XRefsTests.cpp
+++ unittests/clangd/XRefsTests.cpp
@@ -227,6 +227,316 @@
   }
 }
 
+TEST(Hover, All) {
+
+  struct OneTest {
+const char *input;
+const char *expectedHover;
+  };
+
+  OneTest Tests[] = {
+  {
+  R"cpp(// Local variable
+int main() {
+  int bonjour;
+  ^bonjour = 2;
+  int test1 = bonjour;
+}
+  )cpp",
+  "Declared in main\n\nint bonjour",
+  },
+  {
+  R"cpp(// Struct
+namespace ns1 {
+  struct MyClass {};
+} // namespace ns1
+int main() {
+  ns1::My^Class* Params;
+}
+  )cpp",
+  "Declared in namespace ns1\n\nstruct MyClass",
+  },
+  {
+  R"cpp(// Class
+namespace ns1 {
+  class MyClass {};
+} // namespace ns1
+int main() {
+  ns1::My^Class* Params;
+}
+  )cpp",
+  "Declared in namespace ns1\n\nclass MyClass",
+  },
+  {
+  R"cpp(// Union
+namespace ns1 {
+  union MyUnion { int x; int y; };
+} // namespace ns1
+int main() {
+  ns1::My^Union Params;
+}
+  )cpp",
+  "Declared in namespace ns1\n\nunion MyUnion",
+  },
+  {
+  R"cpp(// Function definition via pointer
+int foo(int) {}
+int main() {
+  auto *X = &^foo;
+}
+  )cpp",
+  "Declared in global namespace\n\nint foo(int)",
+  },
+  {
+  R"cpp(// Function declaration via call
+int foo(int);
+int main() {
+  return ^foo(42);
+}
+  )cpp",
+  "Declared in global namespace\n\nint foo(int)",
+  },
+  {
+  R"cpp(// Field
+struct Foo { int x; };
+int main() {
+  Foo bar;
+  bar.^x;
+}
+  )cpp",
+  "Declared in struct Foo\n\nint x",
+  },
+  {
+  R"cpp(// Field with initialization
+struct Foo { int x = 5; };
+int main() {
+  Foo bar;
+  bar.^x;
+}
+  )cpp",
+  "Declared in struct Foo\n\nint x = 5",
+  },
+  {
+  R"cpp(// Static field
+struct Foo { static int x; };
+int main() {
+  Foo::^x;
+}
+  )cpp",
+  "Declared in struct Foo\n\nstatic int x",
+  },
+  {
+  R"cpp(// Field, member initializer
+struct Foo {
+  int x;
+  Foo() : ^x(0) {}
+};
+  )cpp",
+  "Declared in struct Foo\n\nint x",
+  },
+  {
+  R"cpp(// Field, GNU old-style field designator
+struct Foo { int x; };
+int main() {
+  Foo bar = { ^x : 1 };
+}
+  )cpp",
+  "Declared in struct Foo\n\nint x",
+  },
+  {
+  R"cpp(// Field, field designator
+struct Foo { int x; };
+int main() {
+  Foo bar = { .^x = 2 };
+}
+  )cpp",
+  "Declared in struct Foo\n\nint x",
+  },
+  {
+  R"cpp(// Method call
+struct Foo { int x(); };
+int main() {
+  Foo bar;
+  bar.^x();
+}
+  )cpp",
+  "Declared in struct Foo\n\nint x()",
+  },
+  {
+  R"cpp(// Static method call
+struct Foo { static int x(); };
+int main() {
+  Foo::^x();
+}
+  )cpp",
+  "Declared in struct Foo\n\nstatic int x()",
+  },
+  {
+  R"cpp(// Typedef
+typedef int Foo;
+int main() {
+  ^Foo bar;
+}
+  )cpp",
+  "Declared in global namespace\n\ntypedef int Foo",
+  },
+  {
+  R"cpp(// Namespace
+namespace ns {
+struct Foo { static 

[PATCH] D43047: [Builtins] Overload __builtin_operator_new/delete to accept an optional alignment parameter.

2018-02-07 Thread Eric Fiselier via Phabricator via cfe-commits
EricWF updated this revision to Diff 133365.
EricWF added a comment.

@rsmith Is this the direction you were thinking?

I haven't updated the tests yet, but I wanted to make the other changes visible 
earlier.


https://reviews.llvm.org/D43047

Files:
  include/clang/Basic/Builtins.def
  include/clang/Sema/Sema.h
  lib/CodeGen/CGBuiltin.cpp
  lib/CodeGen/CGExprCXX.cpp
  lib/CodeGen/CodeGenFunction.h
  lib/Lex/PPMacroExpansion.cpp
  lib/Sema/SemaChecking.cpp
  lib/Sema/SemaExprCXX.cpp
  test/CodeGenCXX/new.cpp
  test/Preprocessor/builtin_operator_new_delete.cpp
  test/SemaCXX/builtin-operator-new-delete-alignment-disabled.cpp
  test/SemaCXX/builtin-operator-new-delete.cpp

Index: test/SemaCXX/builtin-operator-new-delete.cpp
===
--- /dev/null
+++ test/SemaCXX/builtin-operator-new-delete.cpp
@@ -0,0 +1,30 @@
+// RUN: %clang_cc1 -std=c++1z -fsyntax-only -verify %s
+// RUN: %clang_cc1 -std=c++03 -faligned-allocation -fsyntax-only -verify %s
+
+void *NP = 0;
+
+void test_signature() {
+  __builtin_operator_new();   // expected-error {{too few arguments to function call, expected 1, have 0}}
+  __builtin_operator_new(0, 0, 0);// expected-error {{too many arguments to function call, expected 2, have 3}}
+  __builtin_operator_delete();// expected-error {{too few arguments to function call, expected 1, have 0}}
+  __builtin_operator_delete(0, 0, 0); // expected-error {{too many arguments to function call, expected 2, have 3}}
+}
+
+void test_typo_in_args() {
+  __builtin_operator_new(DNE);  // expected-error {{undeclared identifier 'DNE'}}
+  __builtin_operator_new(DNE, DNE2);// expected-error {{undeclared identifier 'DNE'}} expected-error {{'DNE2'}}
+  __builtin_operator_delete(DNE);   // expected-error {{'DNE'}}
+  __builtin_operator_delete(DNE, DNE2); // expected-error {{'DNE'}} expected-error {{'DNE2'}}
+}
+
+void test_arg_types() {
+  __builtin_operator_new(NP);// expected-error {{cannot initialize a parameter of type 'unsigned long' with an lvalue of type 'void *'}}
+  __builtin_operator_new(NP, 0); // expected-error {{cannot initialize a parameter of type 'unsigned long' with an lvalue of type 'void *'}}
+}
+
+void test_return_type() {
+  int w = __builtin_operator_new(42);// expected-error {{cannot initialize a variable of type 'int' with an rvalue of type 'void *'}}
+  int x = __builtin_operator_new(42, 42);// expected-error {{cannot initialize a variable of type 'int' with an rvalue of type 'void *'}}
+  int y = __builtin_operator_delete(NP); // expected-error {{cannot initialize a variable of type 'int' with an rvalue of type 'void'}}
+  int z = __builtin_operator_delete(NP, 42); // expected-error {{cannot initialize a variable of type 'int' with an rvalue of type 'void'}}
+}
Index: test/SemaCXX/builtin-operator-new-delete-alignment-disabled.cpp
===
--- /dev/null
+++ test/SemaCXX/builtin-operator-new-delete-alignment-disabled.cpp
@@ -0,0 +1,14 @@
+// RUN: %clang_cc1 -std=c++03 -fsyntax-only -verify %s
+// RUN: %clang_cc1 -std=c++03 -faligned-allocation -fsyntax-only -verify %s
+// RUN: %clang_cc1 -std=c++1z -fno-aligned-allocation -fsyntax-only -verify %s
+
+void test_disabled() {
+#ifdef __cpp_aligned_new
+  // expected-no-diagnostics
+#else
+  // expected-error@+3 {{__builtin_operator_new with alignment requires aligned allocation support; use -faligned-allocation to enable}}
+  // expected-error@+3 {{__builtin_operator_delete with alignment requires aligned allocation support; use -faligned-allocation to enable}}
+#endif
+  (void)__builtin_operator_new(1, 2);
+  __builtin_operator_delete((void *)0, 2);
+}
Index: test/Preprocessor/builtin_operator_new_delete.cpp
===
--- /dev/null
+++ test/Preprocessor/builtin_operator_new_delete.cpp
@@ -0,0 +1,19 @@
+// RUN: %clang_cc1 -triple x86_64-linux-gnu -std=c++98 %s -fsyntax-only -verify
+// RUN: %clang_cc1 -triple x86_64-linux-gnu -std=c++11 %s -fsyntax-only -verify
+// RUN: %clang_cc1 -triple x86_64-linux-gnu -std=c++17 %s -fsyntax-only -verify
+
+// expected-no-diagnostics
+
+#if __has_builtin(__builtin_operator_new) != __has_builtin(__builtin_operator_delete)
+#error builtins should report same value
+#endif
+
+#if !__has_builtin(__builtin_operator_new) || !__has_builtin(__builtin_operator_delete)
+#error builtins should always be available
+#endif
+
+#if __has_builtin(__builtin_operator_new) != 201802L || \
+__has_builtin(__builtin_operator_delete) != 201802L
+#error builtin should report updated value
+#endif
+
Index: test/CodeGenCXX/new.cpp
===
--- test/CodeGenCXX/new.cpp
+++ test/CodeGenCXX/new.cpp
@@ -1,4 +1,5 @@
-// RUN: %clang_cc1 -triple x86_64-unknown-unknown %s -emit-llvm -o - | FileCheck %s
+// RUN: %clang_cc1 -triple 

[PATCH] D43062: [analyzer] Support CXXTemporaryObjectExpr constructors that have destructors.

2018-02-07 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ created this revision.
NoQ added reviewers: dcoughlin, xazax.hun, a.sidorin, george.karpenkov, szepet.
Herald added subscribers: cfe-commits, rnkovacs.
NoQ added a dependency: D43056: [CFG] [analyzer] Add construction context for 
CXXBindTemporaryExpr..

Patch https://reviews.llvm.org/D43056 adds support for such 
`CXXTemporaryObjectExpr` kind of constructors in the CFG. Here i add a 
straightforward analyzer-side support.

Note that when we don't have destructors (i.e. we have trivial destructors), 
the analyzer inlines the temporary constructor regardless of whether it has a 
destructor in the CFG or not, actually also regardless of whether the target 
region is correct, so it kinda worked before, in simple cases.


Repository:
  rC Clang

https://reviews.llvm.org/D43062

Files:
  lib/StaticAnalyzer/Core/ExprEngineCXX.cpp
  test/Analysis/temporaries.cpp

Index: test/Analysis/temporaries.cpp
===
--- test/Analysis/temporaries.cpp
+++ test/Analysis/temporaries.cpp
@@ -607,22 +607,37 @@
   clang_analyzer_eval(c3.getY() == 2); // expected-warning{{TRUE}}
 
   C c4 = returnTemporaryWithConstruction();
-  // Should be TRUE under TEMPORARY_DTORS once this sort of construction
-  // in the inlined function is supported.
-  clang_analyzer_eval(c4.getX() == 1); // expected-warning{{UNKNOWN}}
-  clang_analyzer_eval(c4.getY() == 2); // expected-warning{{UNKNOWN}}
+  clang_analyzer_eval(c4.getX() == 1);
+  clang_analyzer_eval(c4.getY() == 2);
+#ifdef TEMPORARY_DTORS
+  // expected-warning@-3{{TRUE}}
+  // expected-warning@-3{{TRUE}}
+#else
+  // expected-warning@-6{{UNKNOWN}}
+  // expected-warning@-6{{UNKNOWN}}
+#endif
 
   C c5 = returnTemporaryWithAnotherFunctionWithConstruction();
-  // Should be TRUE under TEMPORARY_DTORS once this sort of construction
-  // in the inlined function is supported.
-  clang_analyzer_eval(c5.getX() == 1); // expected-warning{{UNKNOWN}}
-  clang_analyzer_eval(c5.getY() == 2); // expected-warning{{UNKNOWN}}
+  clang_analyzer_eval(c5.getX() == 1);
+  clang_analyzer_eval(c5.getY() == 2);
+#ifdef TEMPORARY_DTORS
+  // expected-warning@-3{{TRUE}}
+  // expected-warning@-3{{TRUE}}
+#else
+  // expected-warning@-6{{UNKNOWN}}
+  // expected-warning@-6{{UNKNOWN}}
+#endif
 
   C c6 = returnTemporaryWithCopyConstructionWithConstruction();
-  // Should be TRUE under TEMPORARY_DTORS once this sort of construction
-  // in the inlined function is supported.
-  clang_analyzer_eval(c5.getX() == 1); // expected-warning{{UNKNOWN}}
-  clang_analyzer_eval(c5.getY() == 2); // expected-warning{{UNKNOWN}}
+  clang_analyzer_eval(c5.getX() == 1);
+  clang_analyzer_eval(c5.getY() == 2);
+#ifdef TEMPORARY_DTORS
+  // expected-warning@-3{{TRUE}}
+  // expected-warning@-3{{TRUE}}
+#else
+  // expected-warning@-6{{UNKNOWN}}
+  // expected-warning@-6{{UNKNOWN}}
+#endif
 
 #if __cplusplus >= 201103L
 
@@ -683,10 +698,71 @@
   // expected-warning@-6{{UNKNOWN}}
 #endif
 
-  // Should be TRUE under TEMPORARY_DTORS once this sort of construction
-  // in the inlined function is supported.
   D d3 = returnTemporaryWithCopyConstructionWithVariableAndNonTrivialCopy();
-  clang_analyzer_eval(d3.getX() == 1); // expected-warning{{UNKNOWN}}
-  clang_analyzer_eval(d3.getY() == 2); // expected-warning{{UNKNOWN}}
+  clang_analyzer_eval(d3.getX() == 1);
+  clang_analyzer_eval(d3.getY() == 2);
+#ifdef TEMPORARY_DTORS
+  // expected-warning@-3{{TRUE}}
+  // expected-warning@-3{{TRUE}}
+#else
+  // expected-warning@-6{{UNKNOWN}}
+  // expected-warning@-6{{UNKNOWN}}
+#endif
 }
 } // namespace test_return_temporary
+
+namespace test_temporary_object_expr {
+
+class C {
+  int x;
+
+public:
+  C(int x) : x(x) {}
+  ~C() {}
+  int getX() const { return x; }
+};
+
+void test(int coin) {
+  clang_analyzer_eval(C(3).getX() == 3);
+#ifdef TEMPORARY_DTORS
+  // expected-warning@-2{{TRUE}}
+#else
+  // expected-warning@-4{{UNKNOWN}}
+#endif
+
+  const C  = coin ? C(1) : C(2);
+  if (coin) {
+clang_analyzer_eval(c1.getX() == 1);
+#ifdef TEMPORARY_DTORS
+  // expected-warning@-2{{TRUE}}
+#else
+  // expected-warning@-4{{UNKNOWN}}
+#endif
+  } else {
+clang_analyzer_eval(c1.getX() == 2);
+#ifdef TEMPORARY_DTORS
+  // expected-warning@-2{{TRUE}}
+#else
+  // expected-warning@-4{{UNKNOWN}}
+#endif
+  }
+
+  C c2 = coin ? C(1) : C(2);
+  if (coin) {
+clang_analyzer_eval(c2.getX() == 1);
+#ifdef TEMPORARY_DTORS
+  // expected-warning@-2{{TRUE}}
+#else
+  // expected-warning@-4{{UNKNOWN}}
+#endif
+  } else {
+clang_analyzer_eval(c2.getX() == 2);
+#ifdef TEMPORARY_DTORS
+  // expected-warning@-2{{TRUE}}
+#else
+  // expected-warning@-4{{UNKNOWN}}
+#endif
+  }
+}
+
+} // namespace test_temporary_object_expr
Index: lib/StaticAnalyzer/Core/ExprEngineCXX.cpp
===
--- lib/StaticAnalyzer/Core/ExprEngineCXX.cpp
+++ lib/StaticAnalyzer/Core/ExprEngineCXX.cpp
@@ -137,6 +137,9 @@
   } else if (auto *RS = 

[PATCH] D43033: [WinEH] Put funclet bundles on inline asm calls

2018-02-07 Thread Shoaib Meenai via Phabricator via cfe-commits
smeenai added a comment.

LGTM, but I'd like @majnemer to take a look, since I'm not very familiar with 
this code.


https://reviews.llvm.org/D43033



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


[PATCH] D43047: [Builtins] Overload __builtin_operator_new/delete to accept an optional alignment parameter.

2018-02-07 Thread Eric Fiselier via Phabricator via cfe-commits
EricWF added inline comments.



Comment at: lib/CodeGen/CGExprCXX.cpp:1309-1344
 RValue CodeGenFunction::EmitBuiltinNewDeleteCall(const FunctionProtoType *Type,
- const Expr *Arg,
- bool IsDelete) {
+ const Expr *E, bool IsDelete) 
{
+  const auto *TheCall = dyn_cast(E);
+  llvm::SmallVector ArgTypes;
+  for (auto *Arg : TheCall->arguments())
+ArgTypes.push_back(Arg->getType());
   CallArgList Args;

EricWF wrote:
> rsmith wrote:
> > Can we leave this code alone and set the builtin expression's type to 
> > exactly match the type of the chosen function? I really don't want to be 
> > special-casing aligned allocation here. (This change should also cover 
> > sized delete and any future extensions to builtin operator new/delete.)
> That doesn't seem possible as you describe it. Both overloads of the builtin 
> operator share the same `FunctionDecl`, and we can't change the type of that 
> decl to match the selected operator for a particular call.
> 
> I think checking the argument types is the best way to proceed. However, I'll 
> change the types of the call expression to exactly match the types of the 
> selected `operator new/delete`, which will at least clean this up some.
Nevermind... I see what you meant. I can set the `Callee` type and not the type 
of the `CalleeDecl`.


https://reviews.llvm.org/D43047



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


[PATCH] D43047: [Builtins] Overload __builtin_operator_new/delete to accept an optional alignment parameter.

2018-02-07 Thread Eric Fiselier via Phabricator via cfe-commits
EricWF marked an inline comment as done.
EricWF added inline comments.



Comment at: lib/CodeGen/CGExprCXX.cpp:1309-1344
 RValue CodeGenFunction::EmitBuiltinNewDeleteCall(const FunctionProtoType *Type,
- const Expr *Arg,
- bool IsDelete) {
+ const Expr *E, bool IsDelete) 
{
+  const auto *TheCall = dyn_cast(E);
+  llvm::SmallVector ArgTypes;
+  for (auto *Arg : TheCall->arguments())
+ArgTypes.push_back(Arg->getType());
   CallArgList Args;

rsmith wrote:
> Can we leave this code alone and set the builtin expression's type to exactly 
> match the type of the chosen function? I really don't want to be 
> special-casing aligned allocation here. (This change should also cover sized 
> delete and any future extensions to builtin operator new/delete.)
That doesn't seem possible as you describe it. Both overloads of the builtin 
operator share the same `FunctionDecl`, and we can't change the type of that 
decl to match the selected operator for a particular call.

I think checking the argument types is the best way to proceed. However, I'll 
change the types of the call expression to exactly match the types of the 
selected `operator new/delete`, which will at least clean this up some.


https://reviews.llvm.org/D43047



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


[PATCH] D43057: Add Rest of Targets Support to ValidCPUList (enabling march notes)

2018-02-07 Thread Erich Keane via Phabricator via cfe-commits
erichkeane created this revision.
erichkeane added reviewers: samparker, fhahn, rengolin, echristo, craig.topper.
Herald added subscribers: fedor.sergeev, kbarton, aheejin, jgravelle-google, 
sbc100, nhaehnle, nemanjai, sdardis, dylanmckay, jyknight, dschuff, jfb.

A followup to: https://reviews.llvm.org/D42978

Most of the rest of the Targets were pretty rote, so this
patch knocks them all out at once.  If you want me to split
anymore out, I can definitely do that too.


Repository:
  rC Clang

https://reviews.llvm.org/D43057

Files:
  lib/Basic/Targets/AMDGPU.cpp
  lib/Basic/Targets/AMDGPU.h
  lib/Basic/Targets/AVR.cpp
  lib/Basic/Targets/AVR.h
  lib/Basic/Targets/BPF.cpp
  lib/Basic/Targets/BPF.h
  lib/Basic/Targets/Hexagon.cpp
  lib/Basic/Targets/Hexagon.h
  lib/Basic/Targets/Lanai.cpp
  lib/Basic/Targets/Lanai.h
  lib/Basic/Targets/Mips.cpp
  lib/Basic/Targets/Mips.h
  lib/Basic/Targets/Nios2.h
  lib/Basic/Targets/PPC.cpp
  lib/Basic/Targets/PPC.h
  lib/Basic/Targets/Sparc.cpp
  lib/Basic/Targets/Sparc.h
  lib/Basic/Targets/SystemZ.cpp
  lib/Basic/Targets/SystemZ.h
  lib/Basic/Targets/WebAssembly.cpp
  lib/Basic/Targets/WebAssembly.h
  test/Misc/target-invalid-cpu-note.c

Index: test/Misc/target-invalid-cpu-note.c
===
--- test/Misc/target-invalid-cpu-note.c
+++ test/Misc/target-invalid-cpu-note.c
@@ -18,3 +18,56 @@
 // RUN: not %clang_cc1 -triple nvptx--- -target-cpu not-a-cpu -fsyntax-only %s 2>&1 | FileCheck %s --check-prefix NVPTX
 // NVPTX: error: unknown target CPU 'not-a-cpu'
 // NVPTX: note: valid target CPU values are: sm_20, sm_21, sm_30, sm_32, sm_35, sm_37, sm_50, sm_52, sm_53, sm_60, sm_61, sm_62, sm_70, sm_72
+
+// RUN: not %clang_cc1 -triple r600--- -target-cpu not-a-cpu -fsyntax-only %s 2>&1 | FileCheck %s --check-prefix R600
+// R600: error: unknown target CPU 'not-a-cpu'
+// R600: note: valid target CPU values are: r600, rv610, rv620, rv630, rv635, rs780, rs880, rv670, rv710, rv730, rv740, rv770, palm, cedar, sumo, sumo2, redwood, juniper, hemlock, cypress, barts, turks, caicos, cayman, aruba
+
+
+// RUN: not %clang_cc1 -triple amdgcn--- -target-cpu not-a-cpu -fsyntax-only %s 2>&1 | FileCheck %s --check-prefix AMDGCN
+// AMDGCN: error: unknown target CPU 'not-a-cpu'
+// AMDGCN: note: valid target CPU values are: gfx600, tahiti, gfx601, pitcairn, verde, oland, hainan, gfx700, bonaire, kaveri, gfx701, hawaii, gfx702, gfx703, kabini, mullins, gfx800, iceland, gfx801, carrizo, gfx802, tonga, gfx803, fiji, polaris10, polaris11, gfx804, gfx810, stoney, gfx900, gfx901, gfx902, gfx903
+
+// RUN: not %clang_cc1 -triple wasm64--- -target-cpu not-a-cpu -fsyntax-only %s 2>&1 | FileCheck %s --check-prefix WEBASM
+// WEBASM: error: unknown target CPU 'not-a-cpu'
+// WEBASM: note: valid target CPU values are: mvp, bleeding-edge, generic
+
+// RUN: not %clang_cc1 -triple systemz--- -target-cpu not-a-cpu -fsyntax-only %s 2>&1 | FileCheck %s --check-prefix SYSTEMZ
+// SYSTEMZ: error: unknown target CPU 'not-a-cpu'
+// SYSTEMZ: note: valid target CPU values are: arch8, z10, arch9, z196, arch10, zEC12, arch11, z13, arch12, z14
+
+// RUN: not %clang_cc1 -triple sparc--- -target-cpu not-a-cpu -fsyntax-only %s 2>&1 | FileCheck %s --check-prefix SPARC
+// SPARC: error: unknown target CPU 'not-a-cpu'
+// SPARC: note: valid target CPU values are: v8, supersparc, sparclite, f934, hypersparc, sparclite86x, sparclet, tsc701, v9, ultrasparc, ultrasparc3, niagara, niagara2, niagara3, niagara4, ma2100, ma2150, ma2155, ma2450, ma2455, ma2x5x, ma2080, ma2085, ma2480, ma2485, ma2x8x, myriad2, myriad2.1, myriad2.2, myriad2.3, leon2, at697e, at697f, leon3, ut699, gr712rc, leon4, gr740
+
+// RUN: not %clang_cc1 -triple sparcv9--- -target-cpu not-a-cpu -fsyntax-only %s 2>&1 | FileCheck %s --check-prefix SPARCV9
+// SPARCV9: error: unknown target CPU 'not-a-cpu'
+// SPARCV9: note: valid target CPU values are: v9, ultrasparc, ultrasparc3, niagara, niagara2, niagara3, niagara4
+
+// RUN: not %clang_cc1 -triple powerpc--- -target-cpu not-a-cpu -fsyntax-only %s 2>&1 | FileCheck %s --check-prefix PPC
+// PPC: error: unknown target CPU 'not-a-cpu'
+// PPC: note: valid target CPU values are: generic, 440, 450, 601, 602, 603, 603e, 603ev, 604, 604e, 620, 630, g3, 7400, g4, 7450, g4+, 750, 970, g5, a2, a2q, e500mc, e5500, power3, pwr3, power4, pwr4, power5, pwr5, power5x, pwr5x, power6, pwr6, power6x, pwr6x, power7, pwr7, power8, pwr8, power9, pwr9, powerpc, ppc, powerpc64, ppc64, powerpc64le, ppc64le 
+
+// RUN: not %clang_cc1 -triple nios2--- -target-cpu not-a-cpu -fsyntax-only %s 2>&1 | FileCheck %s --check-prefix NIOS
+// NIOS: error: unknown target CPU 'not-a-cpu'
+// NIOS: note: valid target CPU values are: nios2r1, nios2r2
+
+// RUN: not %clang_cc1 -triple mips--- -target-cpu not-a-cpu -fsyntax-only %s 2>&1 | FileCheck %s --check-prefix MIPS
+// MIPS: error: unknown target CPU 'not-a-cpu'
+// MIPS: note: valid target CPU values are: mips1, mips2, mips3, mips4, 

[PATCH] D16403: Add scope information to CFG

2018-02-07 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added a reviewer: rsmith.
NoQ added a subscriber: rsmith.
NoQ added a comment.

Added @rsmith because we're trying to give him a heads up every time large CFG 
changes are coming, because if we mess up it would affect not only the analyzer 
but the whole compiler through analysis-based compiler warnings, just in case.


Repository:
  rL LLVM

https://reviews.llvm.org/D16403



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


[PATCH] D16403: Add scope information to CFG

2018-02-07 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added a comment.

I poked Devin offline and we agreed that the overall approach is good to go. 
Maxim, thank you for picking it up!

We still don't have scopes for segments of code that don't have any variables 
in them, so i guess it's not yet in the shape where it is super useful for 
loops, but it's already useful for finding use of stale stack variables, which 
was the whole point originally, so i think this should definitely land soon.

In https://reviews.llvm.org/D16403#993512, @m.ostapenko wrote:

> In https://reviews.llvm.org/D16403#992452, @NoQ wrote:
>
> > Am i understanding correctly that while destroying `a` you can still use 
> > the storage of `b` safely? Or should `a` go out of scope before `b` gets 
> > destroyed?
>
>
> AFAIU, when we destroying `a` we can still use the storage of `b` because 
> nothing can be allocated into b's storage between calling destructors for `b` 
> and `a`. So, imho the sequence should look like:
>
>   [B4.5].~A() (Implicit destructor)
>   [B5.3].~A() (Implicit destructor)
>   CFGScopeEnd(b)
>   CFGScopeEnd(a)
>  
>


Thought about it a bit more and this still doesn't look correct to me. Like, 
`a.~A()` is a function call. It can do a lot of unexpected stuff to registers 
and stack space before jumping into the function. And given that `a` and `b` 
are in different scopes (`a` is in loop scope, `b` is in single iteration 
scope), storage of `b` is not protected from such stuff during call to the 
destructor of `a`. So there's definitely something fishy here. I guess scope 
ends and destructors would have to be properly interleaved in all cases of 
exiting multiple scopes.


Repository:
  rL LLVM

https://reviews.llvm.org/D16403



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


[PATCH] D42708: [clang-format] Set ObjCBinPackProtocolList to Never for google style

2018-02-07 Thread Ben Hamilton via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC324553: [clang-format] Set ObjCBinPackProtocolList to Never 
for google style (authored by benhamilton, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D42708?vs=132189=133349#toc

Repository:
  rC Clang

https://reviews.llvm.org/D42708

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


Index: lib/Format/Format.cpp
===
--- lib/Format/Format.cpp
+++ lib/Format/Format.cpp
@@ -710,6 +710,7 @@
   GoogleStyle.IncludeIsMainRegex = "([-_](test|unittest))?$";
   GoogleStyle.IndentCaseLabels = true;
   GoogleStyle.KeepEmptyLinesAtTheStartOfBlocks = false;
+  GoogleStyle.ObjCBinPackProtocolList = FormatStyle::BPS_Never;
   GoogleStyle.ObjCSpaceAfterProperty = false;
   GoogleStyle.ObjCSpaceBeforeProtocolList = true;
   GoogleStyle.PointerAlignment = FormatStyle::PAS_Left;
Index: unittests/Format/FormatTestObjC.cpp
===
--- unittests/Format/FormatTestObjC.cpp
+++ unittests/Format/FormatTestObjC.cpp
@@ -333,13 +333,16 @@
   verifyFormat("@interface Foo (HackStuff) \n"
"+ (id)init;\n"
"@end");
-  Style.BinPackParameters = false;
-  Style.ColumnLimit = 80;
-  verifyFormat("@interface a () <\n"
-   "a,\n"
-   ",\n"
-   "aa,\n"
-   "> {\n"
+  Style.ColumnLimit = 40;
+  // BinPackParameters should be true by default.
+  verifyFormat("void (int e, int e,\n"
+   "  int e, int e);\n");
+  // ObjCBinPackProtocolList should be BPS_Never by default.
+  verifyFormat("@interface f () <\n"
+   "f,\n"
+   "f,\n"
+   "f,\n"
+   "f> {\n"
"}");
 }
 


Index: lib/Format/Format.cpp
===
--- lib/Format/Format.cpp
+++ lib/Format/Format.cpp
@@ -710,6 +710,7 @@
   GoogleStyle.IncludeIsMainRegex = "([-_](test|unittest))?$";
   GoogleStyle.IndentCaseLabels = true;
   GoogleStyle.KeepEmptyLinesAtTheStartOfBlocks = false;
+  GoogleStyle.ObjCBinPackProtocolList = FormatStyle::BPS_Never;
   GoogleStyle.ObjCSpaceAfterProperty = false;
   GoogleStyle.ObjCSpaceBeforeProtocolList = true;
   GoogleStyle.PointerAlignment = FormatStyle::PAS_Left;
Index: unittests/Format/FormatTestObjC.cpp
===
--- unittests/Format/FormatTestObjC.cpp
+++ unittests/Format/FormatTestObjC.cpp
@@ -333,13 +333,16 @@
   verifyFormat("@interface Foo (HackStuff) \n"
"+ (id)init;\n"
"@end");
-  Style.BinPackParameters = false;
-  Style.ColumnLimit = 80;
-  verifyFormat("@interface a () <\n"
-   "a,\n"
-   ",\n"
-   "aa,\n"
-   "> {\n"
+  Style.ColumnLimit = 40;
+  // BinPackParameters should be true by default.
+  verifyFormat("void (int e, int e,\n"
+   "  int e, int e);\n");
+  // ObjCBinPackProtocolList should be BPS_Never by default.
+  verifyFormat("@interface f () <\n"
+   "f,\n"
+   "f,\n"
+   "f,\n"
+   "f> {\n"
"}");
 }
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r324553 - [clang-format] Set ObjCBinPackProtocolList to Never for google style

2018-02-07 Thread Ben Hamilton via cfe-commits
Author: benhamilton
Date: Wed Feb  7 17:49:10 2018
New Revision: 324553

URL: http://llvm.org/viewvc/llvm-project?rev=324553=rev
Log:
[clang-format] Set ObjCBinPackProtocolList to Never for google style

Summary:
This is split off from D42650, and sets ObjCBinPackProtocolList
to Never for the google style.

Depends On D42650

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

Reviewers: krasimir, jolesiak, stephanemoore

Reviewed By: krasimir, jolesiak, stephanemoore

Subscribers: klimek, cfe-commits, hokein, Wizard

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

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

Modified: cfe/trunk/lib/Format/Format.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/Format.cpp?rev=324553=324552=324553=diff
==
--- cfe/trunk/lib/Format/Format.cpp (original)
+++ cfe/trunk/lib/Format/Format.cpp Wed Feb  7 17:49:10 2018
@@ -710,6 +710,7 @@ FormatStyle getGoogleStyle(FormatStyle::
   GoogleStyle.IncludeIsMainRegex = "([-_](test|unittest))?$";
   GoogleStyle.IndentCaseLabels = true;
   GoogleStyle.KeepEmptyLinesAtTheStartOfBlocks = false;
+  GoogleStyle.ObjCBinPackProtocolList = FormatStyle::BPS_Never;
   GoogleStyle.ObjCSpaceAfterProperty = false;
   GoogleStyle.ObjCSpaceBeforeProtocolList = true;
   GoogleStyle.PointerAlignment = FormatStyle::PAS_Left;

Modified: cfe/trunk/unittests/Format/FormatTestObjC.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTestObjC.cpp?rev=324553=324552=324553=diff
==
--- cfe/trunk/unittests/Format/FormatTestObjC.cpp (original)
+++ cfe/trunk/unittests/Format/FormatTestObjC.cpp Wed Feb  7 17:49:10 2018
@@ -333,13 +333,16 @@ TEST_F(FormatTestObjC, FormatObjCInterfa
   verifyFormat("@interface Foo (HackStuff) \n"
"+ (id)init;\n"
"@end");
-  Style.BinPackParameters = false;
-  Style.ColumnLimit = 80;
-  verifyFormat("@interface a () <\n"
-   "a,\n"
-   ",\n"
-   "aa,\n"
-   "> {\n"
+  Style.ColumnLimit = 40;
+  // BinPackParameters should be true by default.
+  verifyFormat("void (int e, int e,\n"
+   "  int e, int e);\n");
+  // ObjCBinPackProtocolList should be BPS_Never by default.
+  verifyFormat("@interface f () <\n"
+   "f,\n"
+   "f,\n"
+   "f,\n"
+   "f> {\n"
"}");
 }
 


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


[PATCH] D41102: Setup clang-doc frontend framework

2018-02-07 Thread Jake Ehrlich via Phabricator via cfe-commits
jakehehrlich added a comment.

After the comments I just made are resolved, I'm fine with the low level 
details of the parts of this change that are here




Comment at: clang-doc/ClangDoc.cpp:47
+
+comments::FullComment *ClangDocCallback::getComment(const NamedDecl *D) {
+  RawComment *Comment = Context->getRawCommentForDeclNoCache(D);

I don't see any reason this can't be a const method. If I recall a previous 
version you said that it can be it can't be const because it modifies the 
Comment but that shouldn't violate the this being a const method. No 
modifications are being made to any members of this object and no non-const 
references/pointers to any of the members are accessed or needed.



Comment at: clang-doc/ClangDocMapper.cpp:91
+  ClangDocCommentVisitor Visitor(CI);
+  return Visitor.parseComment(C);
+}

If/When you make CurrentCI a reference you should return CI here instead.



Comment at: clang-doc/ClangDocMapper.cpp:181
+  for (comments::Comment *Child : make_range(C->child_begin(), 
C->child_end())) {
+CommentInfo ChildCI;
+ClangDocCommentVisitor Visitor(ChildCI);

Assuming you make the reference changes above, this should be rewritten to 
something like the following:

CurrentCI.Children.emplace_back();
ClangDocCommentVisitor Visitor(CurrentCI.Children.back());
Visitor.parseComment(Child);



Comment at: clang-doc/ClangDocMapper.cpp:266
+bool ClangDocCommentVisitor::isWhitespaceOnly(StringRef S) const {
+  return S.find_first_not_of(" \t\n\v\f\r") == std::string::npos;
+}

Can you use isspace here instead of keeping a list of characters that are 
considered spaces?



Comment at: clang-doc/ClangDocMapper.h:112
+  
+  CommentInfo parseComment(const comments::Comment *C);
+

This shouldn't return CommentInfo if you make CurrentCI a reference



Comment at: clang-doc/ClangDocMapper.h:129
+  
+  CommentInfo CurrentCI;
+};

This should be a CommentInfo& to avoid copy constructing. It also then lets you 
view ClangDocCommentVisitor as a kind of CommentInfo builder


https://reviews.llvm.org/D41102



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


r324552 - Add a testcase for PR36268.

2018-02-07 Thread Rafael Espindola via cfe-commits
Author: rafael
Date: Wed Feb  7 17:17:26 2018
New Revision: 324552

URL: http://llvm.org/viewvc/llvm-project?rev=324552=rev
Log:
Add a testcase for PR36268.

Added:
cfe/trunk/test/CodeGenObjC/availability-dso-local.m

Added: cfe/trunk/test/CodeGenObjC/availability-dso-local.m
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenObjC/availability-dso-local.m?rev=324552=auto
==
--- cfe/trunk/test/CodeGenObjC/availability-dso-local.m (added)
+++ cfe/trunk/test/CodeGenObjC/availability-dso-local.m Wed Feb  7 17:17:26 2018
@@ -0,0 +1,6 @@
+// RUN: %clang_cc1 -triple thumbv7-apple-ios10.0.0 -emit-llvm -fvisibility 
hidden -w %s -o - | FileCheck %s
+
+// CHECK: @"OBJC_CLASS_$_a" = hidden global %struct._class_t
+
+__attribute__((availability(ios, introduced = 11.0))) @interface a @end
+@implementation a @end


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


[PATCH] D43056: [CFG] [analyzer] Add construction context for CXXBindTemporaryExpr.

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

This covers temporary constructors for which a destructor is necessary. It is 
necessary to support `CXXTemporaryObjectExpr` here, which is a "constructor in 
the middle of nowhere" expression like `C()` - it's a sub-class of 
`CXXConstructExpr` which we didn't even notice yet because it didn't appear in 
construction contexts we added support for in the previous patches, but it does 
commonly appear in `CXXBindTemporaryExpr`s and failing to consume the 
construction context would trigger the construction context overwrite assertion.

Note that when the destructor is trivial, `CXXBindTemporaryExpr` is omitted, 
and in that case we don't provide any construction context yet. In such cases 
there's no trigger statement at all, for example the following code:

  struct S {};
  
  void foo() {
S();
  }

would produce the following AST:

  `-FunctionDecl 0x7fea280366a0  line:3:6 foo 'void ()'
`-CompoundStmt 0x7fea28036d98 
  `-CXXTemporaryObjectExpr 0x7fea28036c70  'S' 'void () 
noexcept' zeroing

... and that's it.

So in that case we'd have to make a special kind of construction context that 
merely conveys that we are sure that we are indeed constructing a simple 
temporary object because we were directly told to do so by the programmer. But 
that's another story.


Repository:
  rC Clang

https://reviews.llvm.org/D43056

Files:
  lib/Analysis/CFG.cpp
  test/Analysis/auto-obj-dtors-cfg-output.cpp
  test/Analysis/cfg-rich-constructors.cpp
  test/Analysis/temp-obj-dtors-cfg-output.cpp

Index: test/Analysis/temp-obj-dtors-cfg-output.cpp
===
--- test/Analysis/temp-obj-dtors-cfg-output.cpp
+++ test/Analysis/temp-obj-dtors-cfg-output.cpp
@@ -216,7 +216,8 @@
 // CHECK:   [B2 (ENTRY)]
 // CHECK: Succs (1): B1
 // CHECK:   [B1]
-// CHECK: 1: A() (CXXConstructExpr, class A)
+// WARNINGS: 1: A() (CXXConstructExpr, class A)
+// ANALYZER: 1: A() (CXXConstructExpr, [B1.2], class A)
 // CHECK: 2: [B1.1] (BindTemporary)
 // CHECK: 3: [B1.2] (ImplicitCastExpr, NoOp, const class A)
 // CHECK: 4: [B1.3]
@@ -275,7 +276,8 @@
 // CHECK:   [B2 (ENTRY)]
 // CHECK: Succs (1): B1
 // CHECK:   [B1]
-// CHECK: 1: A() (CXXConstructExpr, class A)
+// WARNINGS: 1: A() (CXXConstructExpr, class A)
+// ANALYZER: 1: A() (CXXConstructExpr, [B1.2], class A)
 // CHECK: 2: [B1.1] (BindTemporary)
 // CHECK: 3: [B1.2] (ImplicitCastExpr, NoOp, const class A)
 // CHECK: 4: [B1.3]
@@ -290,13 +292,15 @@
 // CHECK:   [B2 (ENTRY)]
 // CHECK: Succs (1): B1
 // CHECK:   [B1]
-// CHECK: 1: A() (CXXConstructExpr, class A)
+// WARNINGS: 1: A() (CXXConstructExpr, class A)
+// ANALYZER: 1: A() (CXXConstructExpr, [B1.2], class A)
 // CHECK: 2: [B1.1] (BindTemporary)
 // CHECK: 3: [B1.2].operator int
 // CHECK: 4: [B1.2]
 // CHECK: 5: [B1.4] (ImplicitCastExpr, UserDefinedConversion, int)
 // CHECK: 6: int([B1.5]) (CXXFunctionalCastExpr, NoOp, int)
-// CHECK: 7: B() (CXXConstructExpr, class B)
+// WARNINGS: 7: B() (CXXConstructExpr, class B)
+// ANALYZER: 7: B() (CXXConstructExpr, [B1.8], class B)
 // CHECK: 8: [B1.7] (BindTemporary)
 // CHECK: 9: [B1.8].operator int
 // CHECK:10: [B1.8]
@@ -308,13 +312,15 @@
 // CHECK:16: ~A() (Temporary object destructor)
 // CHECK:17: foo
 // CHECK:18: [B1.17] (ImplicitCastExpr, FunctionToPointerDecay, void (*)(int))
-// CHECK:19: A() (CXXConstructExpr, class A)
+// WARNINGS:19: A() (CXXConstructExpr, class A)
+// ANALYZER:19: A() (CXXConstructExpr, [B1.20], class A)
 // CHECK:20: [B1.19] (BindTemporary)
 // CHECK:21: [B1.20].operator int
 // CHECK:22: [B1.20]
 // CHECK:23: [B1.22] (ImplicitCastExpr, UserDefinedConversion, int)
 // CHECK:24: int([B1.23]) (CXXFunctionalCastExpr, NoOp, int)
-// CHECK:25: B() (CXXConstructExpr, class B)
+// WARNINGS:25: B() (CXXConstructExpr, class B)
+// ANALYZER:25: B() (CXXConstructExpr, [B1.26], class B)
 // CHECK:26: [B1.25] (BindTemporary)
 // CHECK:27: [B1.26].operator int
 // CHECK:28: [B1.26]
@@ -347,7 +353,8 @@
 // CHECK: Preds (2): B4 B5
 // CHECK: Succs (2): B2 B1
 // CHECK:   [B4]
-// CHECK: 1: B() (CXXConstructExpr, class B)
+// WARNINGS: 1: B() (CXXConstructExpr, class B)
+// ANALYZER: 1: B() (CXXConstructExpr, [B4.2], class B)
 // CHECK: 2: [B4.1] (BindTemporary)
 // CHECK: 3: [B4.2].operator bool
 // CHECK: 4: [B4.2]
@@ -358,7 +365,8 @@
 // CHECK: 1: ~A() (Temporary object destructor)
 // CHECK: 2: foo
 // CHECK: 3: [B5.2] (ImplicitCastExpr, FunctionToPointerDecay, void (*)(_Bool))
-// CHECK: 4: A() (CXXConstructExpr, class A)
+// WARNINGS: 4: A() (CXXConstructExpr, 

[PATCH] D42972: Look for 32-bit libraries in /usr/lib32 for MIPS O32 on FreeBSD.

2018-02-07 Thread John Baldwin via Phabricator via cfe-commits
bsdjhb updated this revision to Diff 10.
bsdjhb added a comment.

- Add a test case.


Repository:
  rC Clang

https://reviews.llvm.org/D42972

Files:
  lib/Driver/ToolChains/FreeBSD.cpp
  test/Driver/freebsd.c


Index: test/Driver/freebsd.c
===
--- test/Driver/freebsd.c
+++ test/Driver/freebsd.c
@@ -36,6 +36,12 @@
 // RUN:   | FileCheck --check-prefix=CHECK-LIB32PATHS %s
 // CHECK-LIB32PATHS: libraries: ={{.*:?}}/usr/lib32
 //
+// Check that O32 MIPS uses /usr/lib32 on a 64-bit tree.
+//
+// RUN: %clang -target mips-freebsd12 %s \
+// RUN:   --sysroot=%S/Inputs/multiarch_freebsd64_tree -print-search-dirs 2>&1 
\
+// RUN:   | FileCheck --check-prefix=CHECK-LIB32PATHS %s
+//
 // Check that the new linker flags are passed to FreeBSD
 // RUN: %clang -no-canonical-prefixes -target x86_64-pc-freebsd8 -m32 %s \
 // RUN:   --sysroot=%S/Inputs/multiarch_freebsd64_tree -### 2>&1 \
Index: lib/Driver/ToolChains/FreeBSD.cpp
===
--- lib/Driver/ToolChains/FreeBSD.cpp
+++ lib/Driver/ToolChains/FreeBSD.cpp
@@ -317,6 +317,8 @@
   // When targeting 32-bit platforms, look for '/usr/lib32/crt1.o' and fall
   // back to '/usr/lib' if it doesn't exist.
   if ((Triple.getArch() == llvm::Triple::x86 ||
+   Triple.getArch() == llvm::Triple::mips ||
+   Triple.getArch() == llvm::Triple::mipsel ||
Triple.getArch() == llvm::Triple::ppc) &&
   D.getVFS().exists(getDriver().SysRoot + "/usr/lib32/crt1.o"))
 getFilePaths().push_back(getDriver().SysRoot + "/usr/lib32");


Index: test/Driver/freebsd.c
===
--- test/Driver/freebsd.c
+++ test/Driver/freebsd.c
@@ -36,6 +36,12 @@
 // RUN:   | FileCheck --check-prefix=CHECK-LIB32PATHS %s
 // CHECK-LIB32PATHS: libraries: ={{.*:?}}/usr/lib32
 //
+// Check that O32 MIPS uses /usr/lib32 on a 64-bit tree.
+//
+// RUN: %clang -target mips-freebsd12 %s \
+// RUN:   --sysroot=%S/Inputs/multiarch_freebsd64_tree -print-search-dirs 2>&1 \
+// RUN:   | FileCheck --check-prefix=CHECK-LIB32PATHS %s
+//
 // Check that the new linker flags are passed to FreeBSD
 // RUN: %clang -no-canonical-prefixes -target x86_64-pc-freebsd8 -m32 %s \
 // RUN:   --sysroot=%S/Inputs/multiarch_freebsd64_tree -### 2>&1 \
Index: lib/Driver/ToolChains/FreeBSD.cpp
===
--- lib/Driver/ToolChains/FreeBSD.cpp
+++ lib/Driver/ToolChains/FreeBSD.cpp
@@ -317,6 +317,8 @@
   // When targeting 32-bit platforms, look for '/usr/lib32/crt1.o' and fall
   // back to '/usr/lib' if it doesn't exist.
   if ((Triple.getArch() == llvm::Triple::x86 ||
+   Triple.getArch() == llvm::Triple::mips ||
+   Triple.getArch() == llvm::Triple::mipsel ||
Triple.getArch() == llvm::Triple::ppc) &&
   D.getVFS().exists(getDriver().SysRoot + "/usr/lib32/crt1.o"))
 getFilePaths().push_back(getDriver().SysRoot + "/usr/lib32");
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D42708: [clang-format] Set ObjCBinPackProtocolList to Never for google style

2018-02-07 Thread Stephane Moore via Phabricator via cfe-commits
stephanemoore accepted this revision.
stephanemoore added a comment.

Pretty unanimous from the Google style arbitration side. Looks good to me.


Repository:
  rC Clang

https://reviews.llvm.org/D42708



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


[PATCH] D43044: [DebugInfo] Update Checksum handling in CGDebugInfo

2018-02-07 Thread Adrian Prantl via Phabricator via cfe-commits
aprantl accepted this revision.
aprantl added a comment.
This revision is now accepted and ready to land.

SGTM.


Repository:
  rC Clang

https://reviews.llvm.org/D43044



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


[libcxx] r324545 - Fix size and alignment of array<T, 0>.

2018-02-07 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Wed Feb  7 15:50:25 2018
New Revision: 324545

URL: http://llvm.org/viewvc/llvm-project?rev=324545=rev
Log:
Fix size and alignment of array.

An array T[1] isn't necessarily the same say when it's
a member of a struct. This patch addresses that problem and corrects
the tests to deal with it.

Modified:
libcxx/trunk/include/__config
libcxx/trunk/include/array
libcxx/trunk/test/std/containers/sequences/array/size_and_alignment.pass.cpp

Modified: libcxx/trunk/include/__config
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/__config?rev=324545=324544=324545=diff
==
--- libcxx/trunk/include/__config (original)
+++ libcxx/trunk/include/__config Wed Feb  7 15:50:25 2018
@@ -582,6 +582,7 @@ namespace std {
 #define __alignof__ __alignof
 #define _LIBCPP_NORETURN __declspec(noreturn)
 #define _ALIGNAS(x) __declspec(align(x))
+#define _ALIGNAS_TYPE(x) alignas(x)
 #define _LIBCPP_HAS_NO_VARIADICS
 
 #define _LIBCPP_BEGIN_NAMESPACE_STD namespace std {

Modified: libcxx/trunk/include/array
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/array?rev=324545=324544=324545=diff
==
--- libcxx/trunk/include/array (original)
+++ libcxx/trunk/include/array Wed Feb  7 15:50:25 2018
@@ -244,10 +244,11 @@ struct _LIBCPP_TEMPLATE_VIS array<_Tp, 0
 typedef std::reverse_iterator   reverse_iterator;
 typedef std::reverse_iterator const_reverse_iterator;
 
-
 typedef typename conditional::value, const char,
 char>::type _CharType;
-_ALIGNAS(alignment_of<_Tp[1]>::value) _CharType __elems_[sizeof(_Tp[1])];
+
+struct  _ArrayInStructT { _Tp __data_[1]; };
+_ALIGNAS_TYPE(_ArrayInStructT) _CharType __elems_[sizeof(_ArrayInStructT)];
 
 // No explicit construct/copy/destroy for aggregate type
 _LIBCPP_INLINE_VISIBILITY void fill(const value_type&) {

Modified: 
libcxx/trunk/test/std/containers/sequences/array/size_and_alignment.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/sequences/array/size_and_alignment.pass.cpp?rev=324545=324544=324545=diff
==
--- 
libcxx/trunk/test/std/containers/sequences/array/size_and_alignment.pass.cpp 
(original)
+++ 
libcxx/trunk/test/std/containers/sequences/array/size_and_alignment.pass.cpp 
Wed Feb  7 15:50:25 2018
@@ -21,12 +21,26 @@
 
 #include "test_macros.h"
 
+
+template 
+struct MyArray {
+  T elems[Size];
+};
+
 template 
 void test() {
   typedef T CArrayT[Size == 0 ? 1 : Size];
   typedef std::array ArrayT;
-  static_assert(sizeof(CArrayT) == sizeof(ArrayT), "");
-  static_assert(TEST_ALIGNOF(CArrayT) == TEST_ALIGNOF(ArrayT), "");
+  typedef MyArray MyArrayT;
+  static_assert(sizeof(ArrayT) == sizeof(CArrayT), "");
+  static_assert(sizeof(ArrayT) == sizeof(MyArrayT), "");
+  static_assert(TEST_ALIGNOF(ArrayT) == TEST_ALIGNOF(MyArrayT), "");
+#if defined(_LIBCPP_VERSION)
+  ArrayT a;
+  ((void)a);
+  static_assert(sizeof(ArrayT) == sizeof(a.__elems_), "");
+  static_assert(TEST_ALIGNOF(ArrayT) == __alignof__(a.__elems_), "");
+#endif
 }
 
 template 
@@ -44,6 +58,8 @@ struct TEST_ALIGNAS(TEST_ALIGNOF(std::ma
   char data[1000];
 };
 
+//static_assert(sizeof(void*) == 4, "");
+
 int main() {
   test_type();
   test_type();


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


[PATCH] D42779: [analyzer] NFC: Make sure we don't ever inline the constructor for which the temporary destructor is noreturn and missing.

2018-02-07 Thread Devin Coughlin via Phabricator via cfe-commits
dcoughlin accepted this revision.
dcoughlin added a comment.
This revision is now accepted and ready to land.

This looks good to me, but I think you should include your explanatory comments 
in the commit message to the comment itself to help future violators of the 
assertion out!




Comment at: lib/StaticAnalyzer/Core/ExprEngineCXX.cpp:335
+  // Otherwise there's nothing wrong with inlining such constructor.
+  assert(!DstEvaluated.empty() &&
+ "We should not have inlined this constructor!");

Can you add to the comment the instructions from the commit message on what to 
do if the assertion fires? I..e, "If any new code violates this assertion, it 
should be fixed by not inlining this constructor when -analyzer-config 
cfg-temporary-dtors is set to false."

This will give someone who violates the assertion concrete steps to take.


https://reviews.llvm.org/D42779



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


[PATCH] D26596: [RFC] Add _LIBCPP_NO_DISCARD and apply it to `Container::empty()`, `unique_ptr::release()`, and `Lockable::try_lock()`

2018-02-07 Thread Marshall Clow via Phabricator via cfe-commits
mclow.lists requested changes to this revision.
mclow.lists added a comment.
This revision now requires changes to proceed.

Since we've implemented P0600, I believe that this patch is out of date.
The correct macro is `_LIBCPP_NODISCARD_AFTER_CXX17`, and I think that several 
of these cases are now handled.


https://reviews.llvm.org/D26596



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


[PATCH] D42987: [libc++abi] fix compilation in C++17 mode

2018-02-07 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL324542: Fix compilation in C++17 mode. (authored by rsmith, 
committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D42987?vs=133089=133323#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D42987

Files:
  libcxxabi/trunk/src/cxa_exception.cpp


Index: libcxxabi/trunk/src/cxa_exception.cpp
===
--- libcxxabi/trunk/src/cxa_exception.cpp
+++ libcxxabi/trunk/src/cxa_exception.cpp
@@ -11,6 +11,8 @@
 //  
 
//===--===//
 
+#define _LIBCPP_ENABLE_CXX17_REMOVED_UNEXPECTED_FUNCTIONS
+
 #include "cxxabi.h"
 
 #include // for std::terminate


Index: libcxxabi/trunk/src/cxa_exception.cpp
===
--- libcxxabi/trunk/src/cxa_exception.cpp
+++ libcxxabi/trunk/src/cxa_exception.cpp
@@ -11,6 +11,8 @@
 //  
 //===--===//
 
+#define _LIBCPP_ENABLE_CXX17_REMOVED_UNEXPECTED_FUNCTIONS
+
 #include "cxxabi.h"
 
 #include // for std::terminate
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[libcxxabi] r324542 - Fix compilation in C++17 mode.

2018-02-07 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Wed Feb  7 15:23:23 2018
New Revision: 324542

URL: http://llvm.org/viewvc/llvm-project?rev=324542=rev
Log:
Fix compilation in C++17 mode.

C++17 removes `std::unexpected_handler`, but libc++abi needs it to define
`__cxa_exception`. When building against libc++, this is easily rectified by
telling libc++ we're building the library. We already do this in the other
places where we need these symbols.

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

Modified:
libcxxabi/trunk/src/cxa_exception.cpp

Modified: libcxxabi/trunk/src/cxa_exception.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxxabi/trunk/src/cxa_exception.cpp?rev=324542=324541=324542=diff
==
--- libcxxabi/trunk/src/cxa_exception.cpp (original)
+++ libcxxabi/trunk/src/cxa_exception.cpp Wed Feb  7 15:23:23 2018
@@ -11,6 +11,8 @@
 //  
 
//===--===//
 
+#define _LIBCPP_ENABLE_CXX17_REMOVED_UNEXPECTED_FUNCTIONS
+
 #include "cxxabi.h"
 
 #include // for std::terminate


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


[PATCH] D42987: [libc++abi] fix compilation in C++17 mode

2018-02-07 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith added a comment.

I defined `_LIBCPP_BUILDING_LIBRARY` instead to match the existing code in 
libc++abi (stdlib_exception.cpp, stdlib_new_delete.cpp), which uses the 
`_BUILDING_LIBRARY` macro as a general way to say "give me all the symbols 
because I'm building the library". That seemed to match the semantics of this 
code better than a macro whose purpose is "I am writing user code that is still 
using this removed symbol".

But I don't really care. If you two prefer the other macro, that's fine with me 
:)

(Would there be any interest in a patch that just unconditionally defines 
`_LIBCPP_BUILDING_LIBRARY` throughout the libc++abi compilation instead of this 
change?)


Repository:
  rCXXA libc++abi

https://reviews.llvm.org/D42987



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


[PATCH] D43047: [Builtins] Overload __builtin_operator_new/delete to accept an optional alignment parameter.

2018-02-07 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith added inline comments.



Comment at: lib/CodeGen/CGExprCXX.cpp:1309-1344
 RValue CodeGenFunction::EmitBuiltinNewDeleteCall(const FunctionProtoType *Type,
- const Expr *Arg,
- bool IsDelete) {
+ const Expr *E, bool IsDelete) 
{
+  const auto *TheCall = dyn_cast(E);
+  llvm::SmallVector ArgTypes;
+  for (auto *Arg : TheCall->arguments())
+ArgTypes.push_back(Arg->getType());
   CallArgList Args;

Can we leave this code alone and set the builtin expression's type to exactly 
match the type of the chosen function? I really don't want to be special-casing 
aligned allocation here. (This change should also cover sized delete and any 
future extensions to builtin operator new/delete.)



Comment at: lib/Lex/PPMacroExpansion.cpp:1242-1243
+  // Clang specific changes which libc++ needs to be able to detect
+  .Case("has_aligned_builtin_operator_new",
+LangOpts.CPlusPlus && LangOpts.AlignedAllocation)
+

Hmm, I'd prefer something that just indicates that we have generalized 
`__builtin_operator_new/delete` support, so that you can use it for sized 
delete too.



Comment at: lib/Sema/SemaChecking.cpp:2918-2962
+  if (TheCall->getNumArgs() < 1) {
+Diag(TheCall->getLocEnd(), diag::err_typecheck_call_too_few_args)
+<< 0 << 1 << TheCall->getNumArgs()
+<< TheCall->getCallee()->getSourceRange();
+return ExprError();
+  } else if (TheCall->getNumArgs() > 2) {
+Diag(TheCall->getArg(2)->getLocStart(),

Here's how I think this should work:

 * perform overload resolution for an `operator new` or `operator delete` with 
the given arguments
 * if the selected function is not a usual allocation / deallocation function, 
issue an error
 * set the type of the callee expression to the type of the selected function 
and convert the parameters as if you were going to call the selected function 
(so that codegen can find the correct callee again)


https://reviews.llvm.org/D43047



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


[PATCH] D42614: AST: support ObjC lifetime qualifiers in MS ABI

2018-02-07 Thread Saleem Abdulrasool via Phabricator via cfe-commits
compnerd added a comment.

@rjmccall, I've updated the approach and no longer abuse the existing 
decoration styles.  This uses a custom namespace with artificial types to 
differentiate the types.  I've also ensured that the parameter types do not 
encode the type information.


Repository:
  rC Clang

https://reviews.llvm.org/D42614



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


[PATCH] D42614: AST: support ObjC lifetime qualifiers in MS ABI

2018-02-07 Thread Saleem Abdulrasool via Phabricator via cfe-commits
compnerd updated this revision to Diff 133319.
compnerd edited the summary of this revision.
compnerd added a comment.

Address comments from @rjmccall


Repository:
  rC Clang

https://reviews.llvm.org/D42614

Files:
  lib/AST/MicrosoftMangle.cpp
  test/CodeGenObjCXX/msabi-objc-extensions.mm
  test/CodeGenObjCXX/msabi-protocol-conformance.mm

Index: test/CodeGenObjCXX/msabi-protocol-conformance.mm
===
--- test/CodeGenObjCXX/msabi-protocol-conformance.mm
+++ /dev/null
@@ -1,34 +0,0 @@
-// RUN: %clang_cc1 -triple thumbv7-windows-msvc -fobjc-runtime=ios-6.0 -o - -emit-llvm %s | FileCheck %s
-
-@protocol P;
-@protocol Q;
-
-@class I;
-
-void f(id, id, id, id) {}
-// CHECK-LABEL: "\01?f@@YAXPAU?$objc_object@YPPAUobjc_object@@01@Z"
-
-void f(id, id, id, id) {}
-// CHECK-LABEL: "\01?f@@YAXPAUobjc_object@@PAU?$objc_object@YP10@Z"
-
-void f(id, id) {}
-// CHECK-LABEL: "\01?f@@YAXPAU?$objc_object@YP0@Z"
-
-void f(id) {}
-// CHECK-LABEL: "\01?f@@YAXPAU?$objc_object@YP@Z"
-
-void f(id) {}
-// CHECK-LABEL: "\01?f@@YAXPAU?$objc_object@YP@@YQ@Z"
-
-void f(Class) {}
-// CHECK-LABEL: "\01?f@@YAXPAU?$objc_class@YP@Z"
-
-void f(Class) {}
-// CHECK-LABEL: "\01?f@@YAXPAU?$objc_class@YP@@YQ@Z"
-
-void f(I *) {}
-// CHECK-LABEL: "\01?f@@YAXPAU?$I@YP@Z"
-
-void f(I *) {}
-// CHECK-LABEL: "\01?f@@YAXPAU?$I@YP@@YQ@Z"
-
Index: test/CodeGenObjCXX/msabi-objc-extensions.mm
===
--- /dev/null
+++ test/CodeGenObjCXX/msabi-objc-extensions.mm
@@ -0,0 +1,66 @@
+// RUN: %clang_cc1 -triple thumbv7-windows-msvc -fobjc-runtime=ios-6.0 -fobjc-arc -o - -emit-llvm %s | FileCheck %s
+
+@protocol P;
+@protocol Q;
+
+@class I;
+
+void f(id, id, id, id) {}
+// CHECK-LABEL: "\01?f@@YAXPAU?$objc_object@U?$Protocol@UP@@@__ObjCPAUobjc_object@@01@Z"
+
+void f(id, id, id, id) {}
+// CHECK-LABEL: "\01?f@@YAXPAUobjc_object@@PAU?$objc_object@U?$Protocol@UP@@@__ObjC10@Z"
+
+void f(id, id) {}
+// CHECK-LABEL: "\01?f@@YAXPAU?$objc_object@U?$Protocol@UP@@@__ObjC0@Z"
+
+void f(id) {}
+// CHECK-LABEL: "\01?f@@YAXPAU?$objc_object@U?$Protocol@UP@@@__ObjC@Z"
+
+void f(id) {}
+// CHECK-LABEL: "\01?f@@YAXPAU?$objc_object@U?$Protocol@UP@@@__ObjC@@U?$Protocol@UQ@@@2Z"
+
+void f(Class) {}
+// CHECK-LABEL: "\01?f@@YAXPAU?$objc_class@U?$Protocol@UP@@@__ObjC@Z"
+
+void f(Class) {}
+// CHECK-LABEL: "\01?f@@YAXPAU?$objc_class@U?$Protocol@UP@@@__ObjC@@U?$Protocol@UQ@@@2Z"
+
+void f(I *) {}
+// CHECK-LABEL: "\01?f@@YAXPAU?$I@U?$Protocol@UP@@@__ObjC@Z"
+
+void f(I *) {}
+// CHECK-LABEL: "\01?f@@YAXPAU?$I@U?$Protocol@UP@@@__ObjC@@U?$Protocol@UQ@@@2Z"
+
+template 
+struct S {};
+
+void f(S<__unsafe_unretained id>) {}
+// CHECK-LABEL: "\01?f@@YAXU?$S@PAUobjc_object@Z"
+
+void f(S<__autoreleasing id>) {}
+// CHECK-LABEL: "\01?f@@YAXU?$S@U?$Autoreleasing@PAUobjc_object@@@__ObjC@Z"
+
+void f(S<__strong id>) {}
+// CHECK-LABEL: "\01?f@@YAXU?$S@U?$Strong@PAUobjc_object@@@__ObjC@Z"
+
+void f(S<__weak id>) {}
+// CHECK-LABEL: "\01?f@@YAXU?$S@U?$Weak@PAUobjc_object@@@__ObjC@Z"
+
+void w(__weak id) {}
+// CHECK-LABEL: "\01?w@@YAXPAUobjc_object@@@Z"
+
+void s(__strong id) {}
+// CHECK-LABEL: "\01?s@@YAXPAUobjc_object@@@Z"
+
+void a(__autoreleasing id) {}
+// CHECK-LABEL: "\01?a@@YAXPAUobjc_object@@@Z"
+
+void u(__unsafe_unretained id) {}
+// CHECK-LABEL: "\01?u@@YAXPAUobjc_object@@@Z"
+
+S<__autoreleasing id> g() { return S<__autoreleasing id>(); }
+// CHECK-LABEL: "\01?g@@YA?AU?$S@U?$Autoreleasing@PAUobjc_object@@@__ObjCXZ"
+
+__autoreleasing id h() { return nullptr; }
+// CHECK-LABEL: "\01?h@@YAPAUobjc_object@@XZ"
Index: lib/AST/MicrosoftMangle.cpp
===
--- lib/AST/MicrosoftMangle.cpp
+++ lib/AST/MicrosoftMangle.cpp
@@ -362,6 +362,10 @@
   const TemplateArgumentList );
   void mangleTemplateArg(const TemplateDecl *TD, const TemplateArgument ,
  const NamedDecl *Parm);
+
+  void mangleObjCProtocol(const ObjCProtocolDecl *PD);
+  void mangleObjCLifetime(const QualType T, Qualifiers Quals,
+  SourceRange Range);
 };
 }

@@ -1456,6 +1460,47 @@
   }
 }

+void MicrosoftCXXNameMangler::mangleObjCProtocol(const ObjCProtocolDecl *PD) {
+  llvm::SmallString<64> TemplateMangling;
+  llvm::raw_svector_ostream Stream(TemplateMangling);
+  MicrosoftCXXNameMangler Extra(Context, Stream);
+
+  Stream << "?$";
+  Extra.mangleSourceName("Protocol");
+  Extra.mangleArtificalTagType(TTK_Struct, PD->getName());
+
+  mangleArtificalTagType(TTK_Struct, TemplateMangling, {"__ObjC"});
+}
+
+void MicrosoftCXXNameMangler::mangleObjCLifetime(const QualType Type,
+ Qualifiers Quals,
+ SourceRange Range) {
+  llvm::SmallString<64> 

r324540 - [NFCi] Replace a couple of usages of const StringRef& with StringRef

2018-02-07 Thread Erich Keane via cfe-commits
Author: erichkeane
Date: Wed Feb  7 15:04:38 2018
New Revision: 324540

URL: http://llvm.org/viewvc/llvm-project?rev=324540=rev
Log:
[NFCi] Replace a couple of usages of const StringRef& with StringRef

No sense passing these by reference when a copy is about as free, and
saves on potential indirection later.

Modified:
cfe/trunk/include/clang/Basic/TargetInfo.h
cfe/trunk/lib/Basic/Targets/SystemZ.cpp
cfe/trunk/lib/Basic/Targets/SystemZ.h
cfe/trunk/lib/Basic/Targets/X86.h

Modified: cfe/trunk/include/clang/Basic/TargetInfo.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/TargetInfo.h?rev=324540=324539=324540=diff
==
--- cfe/trunk/include/clang/Basic/TargetInfo.h (original)
+++ cfe/trunk/include/clang/Basic/TargetInfo.h Wed Feb  7 15:04:38 2018
@@ -623,9 +623,9 @@ public:
   /// ReturnCanonical = true and Name = "rax", will return "ax".
   StringRef getNormalizedGCCRegisterName(StringRef Name,
  bool ReturnCanonical = false) const;
- 
-  virtual StringRef getConstraintRegister(const StringRef ,
-  const StringRef ) const {
+
+  virtual StringRef getConstraintRegister(StringRef Constraint,
+  StringRef Expression) const {
 return "";
   }
 

Modified: cfe/trunk/lib/Basic/Targets/SystemZ.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets/SystemZ.cpp?rev=324540=324539=324540=diff
==
--- cfe/trunk/lib/Basic/Targets/SystemZ.cpp (original)
+++ cfe/trunk/lib/Basic/Targets/SystemZ.cpp Wed Feb  7 15:04:38 2018
@@ -83,7 +83,7 @@ bool SystemZTargetInfo::validateAsmConst
   }
 }
 
-int SystemZTargetInfo::getISARevision(const StringRef ) const {
+int SystemZTargetInfo::getISARevision(StringRef Name) const {
   return llvm::StringSwitch(Name)
   .Cases("arch8", "z10", 8)
   .Cases("arch9", "z196", 9)

Modified: cfe/trunk/lib/Basic/Targets/SystemZ.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets/SystemZ.h?rev=324540=324539=324540=diff
==
--- cfe/trunk/lib/Basic/Targets/SystemZ.h (original)
+++ cfe/trunk/lib/Basic/Targets/SystemZ.h Wed Feb  7 15:04:38 2018
@@ -76,7 +76,7 @@ public:
 return TargetInfo::SystemZBuiltinVaList;
   }
 
-  int getISARevision(const StringRef ) const;
+  int getISARevision(StringRef Name) const;
 
   bool isValidCPUName(StringRef Name) const override {
 return getISARevision(Name) != -1;

Modified: cfe/trunk/lib/Basic/Targets/X86.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets/X86.h?rev=324540=324539=324540=diff
==
--- cfe/trunk/lib/Basic/Targets/X86.h (original)
+++ cfe/trunk/lib/Basic/Targets/X86.h Wed Feb  7 15:04:38 2018
@@ -175,8 +175,8 @@ public:
 return "~{dirflag},~{fpsr},~{flags}";
   }
 
-  StringRef getConstraintRegister(const StringRef ,
-  const StringRef ) const override {
+  StringRef getConstraintRegister(StringRef Constraint,
+  StringRef Expression) const override {
 StringRef::iterator I, E;
 for (I = Constraint.begin(), E = Constraint.end(); I != E; ++I) {
   if (isalpha(*I))


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


r324539 - Don't try to use copy relocations with tls variables.

2018-02-07 Thread Rafael Espindola via cfe-commits
Author: rafael
Date: Wed Feb  7 15:04:06 2018
New Revision: 324539

URL: http://llvm.org/viewvc/llvm-project?rev=324539=rev
Log:
Don't try to use copy relocations with tls variables.

Should fix the lldb bot.

Modified:
cfe/trunk/lib/CodeGen/CodeGenModule.cpp
cfe/trunk/test/CodeGen/dso-local-executable.c

Modified: cfe/trunk/lib/CodeGen/CodeGenModule.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenModule.cpp?rev=324539=324538=324539=diff
==
--- cfe/trunk/lib/CodeGen/CodeGenModule.cpp (original)
+++ cfe/trunk/lib/CodeGen/CodeGenModule.cpp Wed Feb  7 15:04:06 2018
@@ -746,9 +746,10 @@ static bool shouldAssumeDSOLocal(const C
 return false;
 
   // If we can use copy relocations we can assume it is local.
-  if (isa(D) &&
-  (RM == llvm::Reloc::Static || CGOpts.PIECopyRelocations))
-return true;
+  if (auto *VD = dyn_cast(D))
+if (VD->getTLSKind() == VarDecl::TLS_None &&
+(RM == llvm::Reloc::Static || CGOpts.PIECopyRelocations))
+  return true;
 
   // If we can use a plt entry as the symbol address we can assume it
   // is local.

Modified: cfe/trunk/test/CodeGen/dso-local-executable.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/dso-local-executable.c?rev=324539=324538=324539=diff
==
--- cfe/trunk/test/CodeGen/dso-local-executable.c (original)
+++ cfe/trunk/test/CodeGen/dso-local-executable.c Wed Feb  7 15:04:06 2018
@@ -4,6 +4,8 @@
 // STATIC-DAG: declare dso_local void @foo()
 // STATIC-DAG: @baz = dso_local global i32 42
 // STATIC-DAG: define dso_local i32* @zed()
+// STATIC-DAG: @thread_var = external thread_local global i32
+// STATIC-DAG: @local_thread_var = dso_local thread_local global i32 42
 
 // RUN: %clang_cc1 -triple x86_64-pc-linux -emit-llvm -pic-is-pie 
-mpie-copy-relocations %s -o - | FileCheck --check-prefix=PIE-COPY %s
 // PIE-COPY-DAG: @bar = external dso_local global i32
@@ -11,6 +13,8 @@
 // PIE-COPY-DAG: declare void @foo()
 // PIE-COPY-DAG: @baz = dso_local global i32 42
 // PIE-COPY-DAG: define dso_local i32* @zed()
+// PIE-COPY-DAG: @thread_var = external thread_local global i32
+// PIE-COPY-DAG: @local_thread_var = dso_local thread_local global i32 42
 
 // RUN: %clang_cc1 -triple x86_64-pc-linux -emit-llvm -pic-is-pie %s -o - | 
FileCheck --check-prefix=PIE %s
 // PIE-DAG: @bar = external global i32
@@ -18,6 +22,8 @@
 // PIE-DAG: declare void @foo()
 // PIE-DAG: @baz = dso_local global i32 42
 // PIE-DAG: define dso_local i32* @zed()
+// PIE-DAG: @thread_var = external thread_local global i32
+// PIE-DAG: @local_thread_var = dso_local thread_local global i32 42
 
 // RUN: %clang_cc1 -triple x86_64-pc-linux -emit-llvm -mrelocation-model 
static -fno-plt %s -o - | FileCheck --check-prefix=NOPLT %s
 // NOPLT-DAG: @bar = external dso_local global i32
@@ -25,6 +31,8 @@
 // NOPLT-DAG: declare void @foo()
 // NOPLT-DAG: @baz = dso_local global i32 42
 // NOPLT-DAG: define dso_local i32* @zed()
+// NOPLT-DAG: @thread_var = external thread_local global i32
+// NOPLT-DAG: @local_thread_var = dso_local thread_local global i32 42
 
 // RUN: %clang_cc1 -triple x86_64-pc-linux -emit-llvm -fno-plt -pic-is-pie 
-mpie-copy-relocations %s -o - | FileCheck --check-prefix=PIE-COPY-NOPLT %s
 // PIE-COPY-NOPLT-DAG: @bar = external dso_local global i32
@@ -32,6 +40,8 @@
 // PIE-COPY-NOPLT-DAG: declare void @foo()
 // PIE-COPY-NOPLT-DAG: @baz = dso_local global i32 42
 // PIE-COPY-NOPLT-DAG: define dso_local i32* @zed()
+// PIE-COPY-NOPLT-DAG: @thread_var = external thread_local global i32
+// PIE-COPY-NOPLT-DAG: @local_thread_var = dso_local thread_local global i32 42
 
 // RUN: %clang_cc1 -triple x86_64-pc-linux -emit-llvm -pic-is-pie -fno-plt %s 
-o - | FileCheck --check-prefix=PIE-NO-PLT %s
 // RUN: %clang_cc1 -triple powerpc64le-pc-linux -emit-llvm -mrelocation-model 
static %s -o - | FileCheck --check-prefix=PIE-NO-PLT %s
@@ -40,6 +50,8 @@
 // PIE-NO-PLT-DAG: declare void @foo()
 // PIE-NO-PLT-DAG: @baz = dso_local global i32 42
 // PIE-NO-PLT-DAG: define dso_local i32* @zed()
+// PIE-NO-PLT-DAG: @thread_var = external thread_local global i32
+// PIE-NO-PLT-DAG: @local_thread_var = dso_local thread_local global i32 42
 
 // RUN: %clang_cc1 -triple x86_64-pc-linux -emit-llvm %s -o - | FileCheck 
--check-prefix=SHARED %s
 // SHARED-DAG: @bar = external global i32
@@ -47,6 +59,8 @@
 // SHARED-DAG: declare void @foo()
 // SHARED-DAG: @baz = global i32 42
 // SHARED-DAG: define i32* @zed()
+// SHARED-DAG: @thread_var = external thread_local global i32
+// SHARED-DAG: @local_thread_var = thread_local global i32 42
 
 extern int bar;
 __attribute__((weak)) extern int weak_bar;
@@ -57,3 +71,9 @@ int *zed() {
   foo();
   return baz ? _bar : 
 }
+
+extern __thread int thread_var;
+__thread int local_thread_var = 42;
+int *get_thread_var(int a) {
+  return a ? _var : 

[PATCH] D43047: [Builtins] Overload __builtin_operator_new/delete to accept an optional alignment parameter.

2018-02-07 Thread Eric Fiselier via Phabricator via cfe-commits
EricWF created this revision.
EricWF added reviewers: rsmith, majnemer, aaron.ballman, erik.pilkington, 
bogner, ahatanak.

Libc++'s default allocator uses `__builtin_operator_new` and 
`__builtin_operator_delete` in order to allow the calls to new/delete to be 
ellided. However, libc++ now needs to support over-aligned types in the default 
allocator. In order to support this without disabling the existing optimization 
Clang needs to support calling the aligned new overloads from the builtins.

See llvm.org/PR22634 for more information about the libc++ bug.

This patch changes `__builtin_operator_new`/`__builtin_operator_delete` to 
allow passing an optional alignment parameter. The two parameter overloads will 
forward to the aligned versions of `operator new` and `operator delete`.

Additionally, libc++ needs a way to detect these new overloads. There seems to 
be no great way to do this. This patch chooses to add the feature check 
`has_aligned_builtin_operator_new`. Suggestions on how to better handle this 
case are very welcome!


https://reviews.llvm.org/D43047

Files:
  include/clang/Basic/Builtins.def
  include/clang/Basic/DiagnosticSemaKinds.td
  include/clang/Sema/Sema.h
  lib/CodeGen/CGBuiltin.cpp
  lib/CodeGen/CGExprCXX.cpp
  lib/CodeGen/CodeGenFunction.h
  lib/Lex/PPMacroExpansion.cpp
  lib/Sema/SemaChecking.cpp
  test/CodeGenCXX/new.cpp
  test/Lexer/has_feature_aligned_builtin_new.cpp
  test/SemaCXX/builtin-operator-new-delete-alignment-disabled.cpp
  test/SemaCXX/builtin-operator-new-delete.cpp

Index: test/SemaCXX/builtin-operator-new-delete.cpp
===
--- /dev/null
+++ test/SemaCXX/builtin-operator-new-delete.cpp
@@ -0,0 +1,30 @@
+// RUN: %clang_cc1 -std=c++1z -fsyntax-only -verify %s
+// RUN: %clang_cc1 -std=c++03 -faligned-allocation -fsyntax-only -verify %s
+
+void *NP = 0;
+
+void test_signature() {
+  __builtin_operator_new();   // expected-error {{too few arguments to function call, expected 1, have 0}}
+  __builtin_operator_new(0, 0, 0);// expected-error {{too many arguments to function call, expected 2, have 3}}
+  __builtin_operator_delete();// expected-error {{too few arguments to function call, expected 1, have 0}}
+  __builtin_operator_delete(0, 0, 0); // expected-error {{too many arguments to function call, expected 2, have 3}}
+}
+
+void test_typo_in_args() {
+  __builtin_operator_new(DNE);  // expected-error {{undeclared identifier 'DNE'}}
+  __builtin_operator_new(DNE, DNE2);// expected-error {{undeclared identifier 'DNE'}} expected-error {{'DNE2'}}
+  __builtin_operator_delete(DNE);   // expected-error {{'DNE'}}
+  __builtin_operator_delete(DNE, DNE2); // expected-error {{'DNE'}} expected-error {{'DNE2'}}
+}
+
+void test_arg_types() {
+  __builtin_operator_new(NP);// expected-error {{cannot initialize a parameter of type 'unsigned long' with an lvalue of type 'void *'}}
+  __builtin_operator_new(NP, 0); // expected-error {{cannot initialize a parameter of type 'unsigned long' with an lvalue of type 'void *'}}
+}
+
+void test_return_type() {
+  int w = __builtin_operator_new(42);// expected-error {{cannot initialize a variable of type 'int' with an rvalue of type 'void *'}}
+  int x = __builtin_operator_new(42, 42);// expected-error {{cannot initialize a variable of type 'int' with an rvalue of type 'void *'}}
+  int y = __builtin_operator_delete(NP); // expected-error {{cannot initialize a variable of type 'int' with an rvalue of type 'void'}}
+  int z = __builtin_operator_delete(NP, 42); // expected-error {{cannot initialize a variable of type 'int' with an rvalue of type 'void'}}
+}
Index: test/SemaCXX/builtin-operator-new-delete-alignment-disabled.cpp
===
--- /dev/null
+++ test/SemaCXX/builtin-operator-new-delete-alignment-disabled.cpp
@@ -0,0 +1,14 @@
+// RUN: %clang_cc1 -std=c++03 -fsyntax-only -verify %s
+// RUN: %clang_cc1 -std=c++03 -faligned-allocation -fsyntax-only -verify %s
+// RUN: %clang_cc1 -std=c++1z -fno-aligned-allocation -fsyntax-only -verify %s
+
+void test_disabled() {
+#ifdef __cpp_aligned_new
+  // expected-no-diagnostics
+#else
+  // expected-error@+3 {{__builtin_operator_new with alignment requires aligned allocation support; use -faligned-allocation to enable}}
+  // expected-error@+3 {{__builtin_operator_delete with alignment requires aligned allocation support; use -faligned-allocation to enable}}
+#endif
+  (void)__builtin_operator_new(1, 2);
+  __builtin_operator_delete((void *)0, 2);
+}
Index: test/Lexer/has_feature_aligned_builtin_new.cpp
===
--- /dev/null
+++ test/Lexer/has_feature_aligned_builtin_new.cpp
@@ -0,0 +1,17 @@
+// RUN: %clang_cc1 -E -triple x86_64-linux-gnu -std=c++11 %s -o - | \
+// RUN:   FileCheck --check-prefix=CHECK-NO-BUILTIN %s
+// RUN: %clang_cc1 -E -triple x86_64-linux-gnu 

[PATCH] D43016: Fix for #31362 - ms_abi is implemented incorrectly for larger values (>=16 bytes).

2018-02-07 Thread Dimitry Andric via Phabricator via cfe-commits
dim added a comment.

FWIW, this allows me to build wine again for x86_64, without any crashes or 
assertions. So that looks good, in any case.


Repository:
  rC Clang

https://reviews.llvm.org/D43016



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


r324537 - PR36055: fix computation of *-dependence in nested initializer lists.

2018-02-07 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Wed Feb  7 14:25:16 2018
New Revision: 324537

URL: http://llvm.org/viewvc/llvm-project?rev=324537=rev
Log:
PR36055: fix computation of *-dependence in nested initializer lists.

When we synthesize an implicit inner initializer list when analyzing an outer
initializer list, we add it to the outer list immediately, and then fill in the
inner list. This gives the outer list no chance to update its *-dependence bits
with those of the completed inner list. To fix this, re-add the inner list to
the outer list once it's completed.

Note that we do not recompute the *-dependence bits from scratch when we
complete an outer list; this would give the wrong result for the case where a
designated initializer overwrites a dependent initializer with a non-dependent
one. The resulting list in that case should still be dependent, even though all
traces of the dependence were removed from the semantic form.

Modified:
cfe/trunk/lib/Sema/SemaInit.cpp
cfe/trunk/test/SemaCXX/init-expr-crash.cpp
cfe/trunk/test/SemaTemplate/instantiate-init.cpp

Modified: cfe/trunk/lib/Sema/SemaInit.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaInit.cpp?rev=324537=324536=324537=diff
==
--- cfe/trunk/lib/Sema/SemaInit.cpp (original)
+++ cfe/trunk/lib/Sema/SemaInit.cpp Wed Feb  7 14:25:16 2018
@@ -352,6 +352,7 @@ class InitListChecker {
bool FillWithNoInit = false);
   void FillInEmptyInitializations(const InitializedEntity ,
   InitListExpr *ILE, bool ,
+  InitListExpr *OuterILE, unsigned OuterIndex,
   bool FillWithNoInit = false);
   bool CheckFlexibleArrayInit(const InitializedEntity ,
   Expr *InitExpr, FieldDecl *Field,
@@ -517,12 +518,13 @@ void InitListChecker::FillInEmptyInitFor
 ILE->setInit(Init, BaseInit.getAs());
   } else if (InitListExpr *InnerILE =
  dyn_cast(ILE->getInit(Init))) {
-FillInEmptyInitializations(BaseEntity, InnerILE,
-   RequiresSecondPass, FillWithNoInit);
+FillInEmptyInitializations(BaseEntity, InnerILE, RequiresSecondPass,
+   ILE, Init, FillWithNoInit);
   } else if (DesignatedInitUpdateExpr *InnerDIUE =
dyn_cast(ILE->getInit(Init))) {
 FillInEmptyInitializations(BaseEntity, InnerDIUE->getUpdater(),
-   RequiresSecondPass, /*FillWithNoInit =*/true);
+   RequiresSecondPass, ILE, Init,
+   /*FillWithNoInit =*/true);
   }
 }
 
@@ -605,24 +607,43 @@ void InitListChecker::FillInEmptyInitFor
   } else if (InitListExpr *InnerILE
= dyn_cast(ILE->getInit(Init)))
 FillInEmptyInitializations(MemberEntity, InnerILE,
-   RequiresSecondPass, FillWithNoInit);
+   RequiresSecondPass, ILE, Init, FillWithNoInit);
   else if (DesignatedInitUpdateExpr *InnerDIUE
= dyn_cast(ILE->getInit(Init)))
 FillInEmptyInitializations(MemberEntity, InnerDIUE->getUpdater(),
-   RequiresSecondPass, /*FillWithNoInit =*/ true);
+   RequiresSecondPass, ILE, Init,
+   /*FillWithNoInit =*/true);
 }
 
 /// Recursively replaces NULL values within the given initializer list
 /// with expressions that perform value-initialization of the
-/// appropriate type.
+/// appropriate type, and finish off the InitListExpr formation.
 void
 InitListChecker::FillInEmptyInitializations(const InitializedEntity ,
 InitListExpr *ILE,
 bool ,
+InitListExpr *OuterILE,
+unsigned OuterIndex,
 bool FillWithNoInit) {
   assert((ILE->getType() != SemaRef.Context.VoidTy) &&
  "Should not have void type");
 
+  // If this is a nested initializer list, we might have changed its contents
+  // (and therefore some of its properties, such as instantiation-dependence)
+  // while filling it in. Inform the outer initializer list so that its state
+  // can be updated to match.
+  // FIXME: We should fully build the inner initializers before constructing
+  // the outer InitListExpr instead of mutating AST nodes after they have
+  // been used as subexpressions of other nodes.
+  struct UpdateOuterILEWithUpdatedInit {
+InitListExpr *Outer;
+unsigned OuterIndex;
+~UpdateOuterILEWithUpdatedInit() {
+  if (Outer)
+Outer->setInit(OuterIndex, Outer->getInit(OuterIndex));
+}
+  } UpdateOuterRAII = {OuterILE, OuterIndex};
+
   // A transparent ILE is not performing aggregate initialization and 

[PATCH] D42987: [libc++abi] fix compilation in C++17 mode

2018-02-07 Thread Eric Fiselier via Phabricator via cfe-commits
EricWF accepted this revision.
EricWF added a comment.
This revision is now accepted and ready to land.

I agree with Marshall. This should define 
`_LIBCPP_ENABLE_CXX17_REMOVED_UNEXPECTED_FUNCTIONS` instead of 
`_LIBCPP_BUILDING_LIBRARY`. Other than that, this LGTM.


Repository:
  rCXXA libc++abi

https://reviews.llvm.org/D42987



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


r324535 - Recommit r324107 again.

2018-02-07 Thread Rafael Espindola via cfe-commits
Author: rafael
Date: Wed Feb  7 14:15:33 2018
New Revision: 324535

URL: http://llvm.org/viewvc/llvm-project?rev=324535=rev
Log:
Recommit r324107 again.

The difference from the previous try is that we no longer directly
access function declarations from position independent executables. It
should work, but currently doesn't with some linkers.

It now includes a fix to not mark available_externally definitions as
dso_local.

Original message:

Start setting dso_local in clang.

This starts adding dso_local to clang.

The hope is to eventually have TargetMachine::shouldAssumeDsoLocal go
away. My objective for now is to move enough of it to clang to remove
the need for the TargetMachine one to handle PIE copy relocations and
-fno-plt. With that it should then be easy to implement a
-fno-copy-reloc in clang.

This patch just adds the cases where we assume a symbol to be local
based on the file being compiled for an executable or a shared
library.

Added:
cfe/trunk/test/CodeGen/dso-local-executable.c
cfe/trunk/test/CodeGenCXX/dso-local-executable.cpp
Modified:
cfe/trunk/lib/CodeGen/CGDecl.cpp
cfe/trunk/lib/CodeGen/CGVTT.cpp
cfe/trunk/lib/CodeGen/CGVTables.cpp
cfe/trunk/lib/CodeGen/CodeGenModule.cpp
cfe/trunk/lib/CodeGen/CodeGenModule.h
cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp
cfe/trunk/test/CodeGen/mbackchain-2.c
cfe/trunk/test/CodeGen/mbackchain-3.c
cfe/trunk/test/CodeGen/mips-vector-return.c
cfe/trunk/test/CodeGen/split-stacks.c
cfe/trunk/test/CodeGenCXX/debug-info-static-member.cpp
cfe/trunk/test/CodeGenCXX/debug-info-template.cpp
cfe/trunk/test/CodeGenCXX/float16-declarations.cpp
cfe/trunk/test/CodeGenCXX/split-stacks.cpp
cfe/trunk/test/Driver/lanai-unknown-unknown.cpp
cfe/trunk/test/Driver/le32-unknown-nacl.cpp
cfe/trunk/test/Driver/le64-unknown-unknown.cpp
cfe/trunk/test/Driver/riscv32-toolchain.c
cfe/trunk/test/Driver/riscv64-toolchain.c
cfe/trunk/test/Frontend/ast-codegen.c

Modified: cfe/trunk/lib/CodeGen/CGDecl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDecl.cpp?rev=324535=324534=324535=diff
==
--- cfe/trunk/lib/CodeGen/CGDecl.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGDecl.cpp Wed Feb  7 14:15:33 2018
@@ -240,7 +240,7 @@ llvm::Constant *CodeGenModule::getOrCrea
   getModule(), LTy, Ty.isConstant(getContext()), Linkage, Init, Name,
   nullptr, llvm::GlobalVariable::NotThreadLocal, TargetAS);
   GV->setAlignment(getContext().getDeclAlign().getQuantity());
-  setGlobalVisibility(GV, );
+  setGVProperties(GV, );
 
   if (supportsCOMDAT() && GV->isWeakForLinker())
 GV->setComdat(TheModule.getOrInsertComdat(GV->getName()));
@@ -344,6 +344,7 @@ CodeGenFunction::AddInitializerToStaticV
   OldGV->getThreadLocalMode(),

CGM.getContext().getTargetAddressSpace(D.getType()));
 GV->setVisibility(OldGV->getVisibility());
+GV->setDSOLocal(OldGV->isDSOLocal());
 GV->setComdat(OldGV->getComdat());
 
 // Steal the name of the old global

Modified: cfe/trunk/lib/CodeGen/CGVTT.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGVTT.cpp?rev=324535=324534=324535=diff
==
--- cfe/trunk/lib/CodeGen/CGVTT.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGVTT.cpp Wed Feb  7 14:15:33 2018
@@ -100,7 +100,7 @@ CodeGenVTables::EmitVTTDefinition(llvm::
 VTT->setComdat(CGM.getModule().getOrInsertComdat(VTT->getName()));
 
   // Set the right visibility.
-  CGM.setGlobalVisibility(VTT, RD);
+  CGM.setGVProperties(VTT, RD);
 }
 
 llvm::GlobalVariable *CodeGenVTables::GetAddrOfVTT(const CXXRecordDecl *RD) {

Modified: cfe/trunk/lib/CodeGen/CGVTables.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGVTables.cpp?rev=324535=324534=324535=diff
==
--- cfe/trunk/lib/CodeGen/CGVTables.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGVTables.cpp Wed Feb  7 14:15:33 2018
@@ -51,7 +51,7 @@ llvm::Constant *CodeGenModule::GetAddrOf
 
 static void setThunkVisibility(CodeGenModule , const CXXMethodDecl *MD,
const ThunkInfo , llvm::Function *Fn) {
-  CGM.setGlobalVisibility(Fn, MD);
+  CGM.setGVProperties(Fn, MD);
 }
 
 static void setThunkProperties(CodeGenModule , const ThunkInfo ,
@@ -730,7 +730,7 @@ CodeGenVTables::GenerateConstructionVTab
   // Create the variable that will hold the construction vtable.
   llvm::GlobalVariable *VTable =
 CGM.CreateOrReplaceCXXRuntimeVariable(Name, VTType, Linkage);
-  CGM.setGlobalVisibility(VTable, RD);
+  CGM.setGVProperties(VTable, RD);
 
   // V-tables are always unnamed_addr.
   VTable->setUnnamedAddr(llvm::GlobalValue::UnnamedAddr::Global);

Modified: cfe/trunk/lib/CodeGen/CodeGenModule.cpp
URL: 

[PATCH] D42933: [Sema] Avoid -Wformat warning for NSInteger/NSUInteger 'int' values with %zu/%zi long specifiers

2018-02-07 Thread Alex Lorenz via Phabricator via cfe-commits
arphaman abandoned this revision.
arphaman added subscribers: dcoughlin, dexonsmith.
arphaman added a comment.

Thanks for your input. You're right, this warning is quite correct (even though 
it seems like too much).

I discussed this with @dexonsmith  and @dcoughlin and we decided to keep the 
warning as is and to avoid establishing new guidelines. I'm closing this one.


Repository:
  rC Clang

https://reviews.llvm.org/D42933



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


[PATCH] D36802: AMDGPU: Cleanup most of the macros

2018-02-07 Thread Konstantin Zhuravlyov via Phabricator via cfe-commits
kzhuravl added a comment.

Need to only define canonical names.


https://reviews.llvm.org/D36802



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


[PATCH] D43045: Add NVPTX Support to ValidCPUList (enabling march notes)

2018-02-07 Thread Erich Keane via Phabricator via cfe-commits
erichkeane created this revision.
erichkeane added reviewers: samparker, fhahn, rengolin, echristo, Hahnfeld.
Herald added a subscriber: jholewinski.

A followup to: https://reviews.llvm.org/D42978
This patch adds NVPTX support for
enabling the march notes.


Repository:
  rC Clang

https://reviews.llvm.org/D43045

Files:
  include/clang/Basic/Cuda.h
  lib/Basic/Cuda.cpp
  lib/Basic/Targets/NVPTX.cpp
  lib/Basic/Targets/NVPTX.h
  test/Misc/target-invalid-cpu-note.c


Index: test/Misc/target-invalid-cpu-note.c
===
--- test/Misc/target-invalid-cpu-note.c
+++ test/Misc/target-invalid-cpu-note.c
@@ -14,3 +14,7 @@
 // RUN: not %clang_cc1 -triple x86_64--- -target-cpu not-a-cpu -fsyntax-only 
%s 2>&1 | FileCheck %s --check-prefix X86_64
 // X86_64: error: unknown target CPU 'not-a-cpu'
 // X86_64: note: valid target CPU values are: nocona, core2, penryn, bonnell, 
atom, silvermont, slm, goldmont, nehalem, corei7, westmere, sandybridge, 
corei7-avx, ivybridge, core-avx-i, haswell, core-avx2, broadwell, skylake, 
skylake-avx512, skx, cannonlake, icelake, knl, knm, k8, athlon64, athlon-fx, 
opteron, k8-sse3, athlon64-sse3, opteron-sse3, amdfam10, barcelona, btver1, 
btver2, bdver1, bdver2, bdver3, bdver4, znver1, x86-64
+
+// RUN: not %clang_cc1 -triple nvptx--- -target-cpu not-a-cpu -fsyntax-only %s 
2>&1 | FileCheck %s --check-prefix NVPTX
+// NVPTX: error: unknown target CPU 'not-a-cpu'
+// NVPTX: note: valid target CPU values are: sm_20, sm_21, sm_30, sm_32, 
sm_35, sm_37, sm_50, sm_52, sm_53, sm_60, sm_61, sm_62, sm_70, sm_72
Index: lib/Basic/Targets/NVPTX.h
===
--- lib/Basic/Targets/NVPTX.h
+++ lib/Basic/Targets/NVPTX.h
@@ -98,6 +98,12 @@
 return StringToCudaArch(Name) != CudaArch::UNKNOWN;
   }
 
+  void fillValidCPUList(SmallVectorImpl ) const override {
+for (int i = static_cast(CudaArch::SM_20);
+ i < static_cast(CudaArch::LAST); ++i)
+  Values.emplace_back(CudaArchToString(static_cast(i)));
+  }
+
   bool setCPU(const std::string ) override {
 GPU = StringToCudaArch(Name);
 return GPU != CudaArch::UNKNOWN;
Index: lib/Basic/Targets/NVPTX.cpp
===
--- lib/Basic/Targets/NVPTX.cpp
+++ lib/Basic/Targets/NVPTX.cpp
@@ -157,6 +157,8 @@
 // Set __CUDA_ARCH__ for the GPU specified.
 std::string CUDAArchCode = [this] {
   switch (GPU) {
+  case CudaArch::LAST:
+break;
   case CudaArch::UNKNOWN:
 assert(false && "No GPU arch when compiling CUDA device code.");
 return "";
Index: lib/Basic/Cuda.cpp
===
--- lib/Basic/Cuda.cpp
+++ lib/Basic/Cuda.cpp
@@ -26,6 +26,8 @@
 
 const char *CudaArchToString(CudaArch A) {
   switch (A) {
+  case CudaArch::LAST:
+break;
   case CudaArch::UNKNOWN:
 return "unknown";
   case CudaArch::SM_20:
@@ -133,6 +135,8 @@
 
 CudaVirtualArch VirtualArchForCudaArch(CudaArch A) {
   switch (A) {
+  case CudaArch::LAST:
+break;
   case CudaArch::UNKNOWN:
 return CudaVirtualArch::UNKNOWN;
   case CudaArch::SM_20:
@@ -168,6 +172,8 @@
 
 CudaVersion MinVersionForCudaArch(CudaArch A) {
   switch (A) {
+  case CudaArch::LAST:
+break;
   case CudaArch::UNKNOWN:
 return CudaVersion::UNKNOWN;
   case CudaArch::SM_20:
Index: include/clang/Basic/Cuda.h
===
--- include/clang/Basic/Cuda.h
+++ include/clang/Basic/Cuda.h
@@ -46,6 +46,7 @@
   SM_62,
   SM_70,
   SM_72,
+  LAST,
 };
 const char *CudaArchToString(CudaArch A);
 


Index: test/Misc/target-invalid-cpu-note.c
===
--- test/Misc/target-invalid-cpu-note.c
+++ test/Misc/target-invalid-cpu-note.c
@@ -14,3 +14,7 @@
 // RUN: not %clang_cc1 -triple x86_64--- -target-cpu not-a-cpu -fsyntax-only %s 2>&1 | FileCheck %s --check-prefix X86_64
 // X86_64: error: unknown target CPU 'not-a-cpu'
 // X86_64: note: valid target CPU values are: nocona, core2, penryn, bonnell, atom, silvermont, slm, goldmont, nehalem, corei7, westmere, sandybridge, corei7-avx, ivybridge, core-avx-i, haswell, core-avx2, broadwell, skylake, skylake-avx512, skx, cannonlake, icelake, knl, knm, k8, athlon64, athlon-fx, opteron, k8-sse3, athlon64-sse3, opteron-sse3, amdfam10, barcelona, btver1, btver2, bdver1, bdver2, bdver3, bdver4, znver1, x86-64
+
+// RUN: not %clang_cc1 -triple nvptx--- -target-cpu not-a-cpu -fsyntax-only %s 2>&1 | FileCheck %s --check-prefix NVPTX
+// NVPTX: error: unknown target CPU 'not-a-cpu'
+// NVPTX: note: valid target CPU values are: sm_20, sm_21, sm_30, sm_32, sm_35, sm_37, sm_50, sm_52, sm_53, sm_60, sm_61, sm_62, sm_70, sm_72
Index: lib/Basic/Targets/NVPTX.h
===
--- lib/Basic/Targets/NVPTX.h
+++ lib/Basic/Targets/NVPTX.h
@@ 

[libcxx] r324534 - Stop using __strtonum_fallback on Android.

2018-02-07 Thread Dan Albert via cfe-commits
Author: danalbert
Date: Wed Feb  7 13:58:48 2018
New Revision: 324534

URL: http://llvm.org/viewvc/llvm-project?rev=324534=rev
Log:
Stop using __strtonum_fallback on Android.

Fallback implementations are now provided by bionic when necessary,
which these may conflict with.

Modified:
libcxx/trunk/include/support/android/locale_bionic.h

Modified: libcxx/trunk/include/support/android/locale_bionic.h
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/support/android/locale_bionic.h?rev=324534=324533=324534=diff
==
--- libcxx/trunk/include/support/android/locale_bionic.h (original)
+++ libcxx/trunk/include/support/android/locale_bionic.h Wed Feb  7 13:58:48 
2018
@@ -25,7 +25,6 @@ extern "C" {
 #endif
 
 #include 
-#include 
 
 #endif // defined(__BIONIC__)
 #endif // _LIBCPP_SUPPORT_ANDROID_LOCALE_BIONIC_H


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


[PATCH] D42991: [analyzer] Use EvalCallOptions for destructors as well.

2018-02-07 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ updated this revision to Diff 133299.
NoQ added a comment.

Remove the check in `shouldInlineCall()` as well. It's quite covered by the 
`IsConstructorWithImproperlyModeledTargetRegion` check.


https://reviews.llvm.org/D42991

Files:
  include/clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h
  lib/StaticAnalyzer/Core/ExprEngine.cpp
  lib/StaticAnalyzer/Core/ExprEngineCXX.cpp
  lib/StaticAnalyzer/Core/ExprEngineCallAndReturn.cpp
  test/Analysis/new.cpp

Index: test/Analysis/new.cpp
===
--- test/Analysis/new.cpp
+++ test/Analysis/new.cpp
@@ -311,7 +311,8 @@
 void testArrayDestr() {
   NoReturnDtor *p = new NoReturnDtor[2];
   delete[] p; // Calls the base destructor which aborts, checked below
-  clang_analyzer_eval(true); // no-warning
+   //TODO: clang_analyzer_eval should not be called
+  clang_analyzer_eval(true); // expected-warning{{TRUE}}
 }
 
 // Invalidate Region even in case of default destructor
Index: lib/StaticAnalyzer/Core/ExprEngineCallAndReturn.cpp
===
--- lib/StaticAnalyzer/Core/ExprEngineCallAndReturn.cpp
+++ lib/StaticAnalyzer/Core/ExprEngineCallAndReturn.cpp
@@ -650,7 +650,7 @@
 // initializers for array fields in default move/copy constructors.
 // We still allow construction into ElementRegion targets when they don't
 // represent array elements.
-if (CallOpts.IsArrayConstructorOrDestructor)
+if (CallOpts.IsArrayCtorOrDtor)
   return CIP_DisallowedOnce;
 
 // Inlining constructors requires including initializers in the CFG.
@@ -670,14 +670,14 @@
 if (CtorExpr->getConstructionKind() == CXXConstructExpr::CK_Complete) {
   // If we don't handle temporary destructors, we shouldn't inline
   // their constructors.
-  if (CallOpts.IsConstructorIntoTemporary &&
+  if (CallOpts.IsTemporaryCtorOrDtor &&
   !Opts.includeTemporaryDtorsInCFG())
 return CIP_DisallowedOnce;
 
-  // If we did not construct the correct this-region, it would be pointless
+  // If we did not find the correct this-region, it would be pointless
   // to inline the constructor. Instead we will simply invalidate
   // the fake temporary target.
-  if (CallOpts.IsConstructorWithImproperlyModeledTargetRegion)
+  if (CallOpts.IsCtorOrDtorWithImproperlyModeledTargetRegion)
 return CIP_DisallowedOnce;
 }
 
@@ -693,9 +693,14 @@
 (void)ADC;
 
 // FIXME: We don't handle constructors or destructors for arrays properly.
-if (CallOpts.IsArrayConstructorOrDestructor)
+if (CallOpts.IsArrayCtorOrDtor)
   return CIP_DisallowedOnce;
 
+// If we did not find the correct this-region, it would be pointless
+// to inline the destructor. Instead we will simply invalidate
+// the fake temporary target.
+if (CallOpts.IsCtorOrDtorWithImproperlyModeledTargetRegion)
+  return CIP_DisallowedOnce;
 break;
   }
   case CE_CXXAllocator:
@@ -844,14 +849,6 @@
   AnalysisDeclContextManager  = AMgr.getAnalysisDeclContextManager();
   AnalysisDeclContext *CalleeADC = ADCMgr.getContext(D);
 
-  // Temporary object destructor processing is currently broken, so we never
-  // inline them.
-  // FIXME: Remove this once temp destructors are working.
-  if (isa(Call)) {
-if ((*currBldrCtx->getBlock())[currStmtIdx].getAs())
-  return false;
-  }
-
   // The auto-synthesized bodies are essential to inline as they are
   // usually small and commonly used. Note: we should do this check early on to
   // ensure we always inline these calls.
Index: lib/StaticAnalyzer/Core/ExprEngineCXX.cpp
===
--- lib/StaticAnalyzer/Core/ExprEngineCXX.cpp
+++ lib/StaticAnalyzer/Core/ExprEngineCXX.cpp
@@ -84,16 +84,8 @@
 }
 
 
-/// Returns a region representing the first element of a (possibly
-/// multi-dimensional) array, for the purposes of element construction or
-/// destruction.
-///
-/// On return, \p Ty will be set to the base type of the array.
-///
-/// If the type is not an array type at all, the original value is returned.
-/// Otherwise the "IsArray" flag is set.
-static SVal makeZeroElementRegion(ProgramStateRef State, SVal LValue,
-  QualType , bool ) {
+SVal ExprEngine::makeZeroElementRegion(ProgramStateRef State, SVal LValue,
+   QualType , bool ) {
   SValBuilder  = State->getStateManager().getSValBuilder();
   ASTContext  = SVB.getContext();
 
@@ -128,7 +120,7 @@
 if (CNE->isArray()) {
   // TODO: In fact, we need to call the constructor for every
   // allocated element, not just the first one!
-  CallOpts.IsArrayConstructorOrDestructor = true;
+  CallOpts.IsArrayCtorOrDtor = true;
   return getStoreManager().GetElementZeroRegion(
   MR, 

[PATCH] D43044: [DebugInfo] Update Checksum handling in CGDebugInfo

2018-02-07 Thread Scott Linder via Phabricator via cfe-commits
scott.linder created this revision.
scott.linder added reviewers: aprantl, JDevlieghere.
Herald added a subscriber: cfe-commits.
scott.linder added a dependency: D43043: [DebugInfo] Unify ChecksumKind and 
Checksum value in DIFile.

Update to match new DIFile API.


Repository:
  rC Clang

https://reviews.llvm.org/D43044

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

Index: lib/CodeGen/CGDebugInfo.h
===
--- lib/CodeGen/CGDebugInfo.h
+++ lib/CodeGen/CGDebugInfo.h
@@ -499,8 +499,8 @@
   std::string remapDIPath(StringRef) const;
 
   /// Compute the file checksum debug info for input file ID.
-  llvm::DIFile::ChecksumKind computeChecksum(FileID FID,
- SmallString<32> ) const;
+  Optional
+  computeChecksum(FileID FID, SmallString<32> ) const;
 
   /// Get the file debug info descriptor for the input location.
   llvm::DIFile *getOrCreateFile(SourceLocation Loc);
Index: lib/CodeGen/CGDebugInfo.cpp
===
--- lib/CodeGen/CGDebugInfo.cpp
+++ lib/CodeGen/CGDebugInfo.cpp
@@ -361,19 +361,19 @@
   return StringRef();
 }
 
-llvm::DIFile::ChecksumKind
+Optional
 CGDebugInfo::computeChecksum(FileID FID, SmallString<32> ) const {
   Checksum.clear();
 
   if (!CGM.getCodeGenOpts().EmitCodeView &&
   CGM.getCodeGenOpts().DwarfVersion < 5)
-return llvm::DIFile::CSK_None;
+return None;
 
   SourceManager  = CGM.getContext().getSourceManager();
   bool Invalid;
   llvm::MemoryBuffer *MemBuffer = SM.getBuffer(FID, );
   if (Invalid)
-return llvm::DIFile::CSK_None;
+return None;
 
   llvm::MD5 Hash;
   llvm::MD5::MD5Result Result;
@@ -390,7 +390,6 @@
 // If Location is not valid then use main input file.
 return DBuilder.createFile(remapDIPath(TheCU->getFilename()),
remapDIPath(TheCU->getDirectory()),
-   TheCU->getFile()->getChecksumKind(),
TheCU->getFile()->getChecksum());
 
   SourceManager  = CGM.getContext().getSourceManager();
@@ -400,7 +399,6 @@
 // If the location is not valid then use main input file.
 return DBuilder.createFile(remapDIPath(TheCU->getFilename()),
remapDIPath(TheCU->getDirectory()),
-   TheCU->getFile()->getChecksumKind(),
TheCU->getFile()->getChecksum());
 
   // Cache the results.
@@ -414,21 +412,23 @@
   }
 
   SmallString<32> Checksum;
-  llvm::DIFile::ChecksumKind CSKind =
+  Optional CSKind =
   computeChecksum(SM.getFileID(Loc), Checksum);
+  Optional CSInfo;
+  if (CSKind)
+CSInfo.emplace(*CSKind, Checksum);
 
   llvm::DIFile *F = DBuilder.createFile(remapDIPath(PLoc.getFilename()),
 remapDIPath(getCurrentDirname()),
-CSKind, Checksum);
+CSInfo);
 
   DIFileCache[fname].reset(F);
   return F;
 }
 
 llvm::DIFile *CGDebugInfo::getOrCreateMainFile() {
   return DBuilder.createFile(remapDIPath(TheCU->getFilename()),
  remapDIPath(TheCU->getDirectory()),
- TheCU->getFile()->getChecksumKind(),
  TheCU->getFile()->getChecksum());
 }
 
@@ -473,7 +473,8 @@
 
 void CGDebugInfo::CreateCompileUnit() {
   SmallString<32> Checksum;
-  llvm::DIFile::ChecksumKind CSKind = llvm::DIFile::CSK_None;
+  Optional CSKind;
+  Optional CSInfo;
 
   // Should we be asking the SourceManager for the main file name, instead of
   // accepting it as an argument? This just causes the main file name to
@@ -552,13 +553,16 @@
 break;
   }
 
+  if (CSKind)
+CSInfo.emplace(*CSKind, Checksum);
+
   // Create new compile unit.
   // FIXME - Eliminate TheCU.
   auto  = CGM.getCodeGenOpts();
   TheCU = DBuilder.createCompileUnit(
   LangTag,
   DBuilder.createFile(remapDIPath(MainFileName),
-  remapDIPath(getCurrentDirname()), CSKind, Checksum),
+  remapDIPath(getCurrentDirname()), CSInfo),
   Producer, LO.Optimize || CGOpts.PrepareForLTO || CGOpts.EmitSummaryIndex,
   CGOpts.DwarfDebugFlags, RuntimeVers,
   CGOpts.EnableSplitDwarf ? "" : CGOpts.SplitDwarfFile, EmissionKind,
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[libcxx] r324531 - Fix PR#31454 - 'basic_string::push_back() crashes if sizeof(T)>sizeof(long long)'. We were mishandling the small-string optimization calculations for very large 'characters'. Thi

2018-02-07 Thread Marshall Clow via cfe-commits
Author: marshall
Date: Wed Feb  7 13:30:17 2018
New Revision: 324531

URL: http://llvm.org/viewvc/llvm-project?rev=324531=rev
Log:
Fix PR#31454 - 'basic_string::push_back() crashes if sizeof(T)>sizeof(long 
long)'. We were mishandling the small-string optimization calculations for very 
large 'characters'. This may be an ABI change (change the size of) strings of 
very large 'characters', but since they never worked, I'm not too concerned.

Modified:
libcxx/trunk/include/string

libcxx/trunk/test/std/strings/basic.string/string.modifiers/string_append/push_back.pass.cpp

Modified: libcxx/trunk/include/string
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/string?rev=324531=324530=324531=diff
==
--- libcxx/trunk/include/string (original)
+++ libcxx/trunk/include/string Wed Feb  7 13:30:17 2018
@@ -1363,9 +1363,13 @@ private:
 enum {__alignment = 16};
 static _LIBCPP_INLINE_VISIBILITY
 size_type __recommend(size_type __s) _NOEXCEPT
-{return (__s < __min_cap ? static_cast(__min_cap) :
- __align_it (__s+1)) - 1;}
+{
+if (__s < __min_cap) return static_cast(__min_cap) - 1;
+size_type __guess = __align_it (__s+1) - 1;
+if (__guess == __min_cap) ++__guess;
+return __guess;
+}
 
 inline
 void __init(const value_type* __s, size_type __sz, size_type __reserve);

Modified: 
libcxx/trunk/test/std/strings/basic.string/string.modifiers/string_append/push_back.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/strings/basic.string/string.modifiers/string_append/push_back.pass.cpp?rev=324531=324530=324531=diff
==
--- 
libcxx/trunk/test/std/strings/basic.string/string.modifiers/string_append/push_back.pass.cpp
 (original)
+++ 
libcxx/trunk/test/std/strings/basic.string/string.modifiers/string_append/push_back.pass.cpp
 Wed Feb  7 13:30:17 2018
@@ -48,7 +48,7 @@ int main()
 test(S("12345678901234567890"), 'a', S("12345678901234567890a"));
 }
 #endif
-#if 0
+
 {
 // https://bugs.llvm.org/show_bug.cgi?id=31454
 std::basic_string s;
@@ -57,5 +57,4 @@ int main()
 s.push_back(vl);
 s.push_back(vl);
 }
-#endif
 }


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


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

2018-02-07 Thread Eric Fiselier via Phabricator via cfe-commits
EricWF updated this revision to Diff 133294.
EricWF added reviewers: aaron.ballman, bogner, majnemer.
EricWF added a comment.

Ping.

- Rebase off trunk.


https://reviews.llvm.org/D37035

Files:
  docs/LanguageExtensions.rst
  include/clang/AST/Expr.h
  include/clang/AST/ExprCXX.h
  include/clang/AST/RecursiveASTVisitor.h
  include/clang/AST/SourceLocExprScope.h
  include/clang/AST/Stmt.h
  include/clang/Basic/StmtNodes.td
  include/clang/Basic/TokenKinds.def
  include/clang/Sema/Sema.h
  include/clang/Serialization/ASTBitCodes.h
  lib/AST/ASTImporter.cpp
  lib/AST/Expr.cpp
  lib/AST/ExprCXX.cpp
  lib/AST/ExprClassification.cpp
  lib/AST/ExprConstant.cpp
  lib/AST/ItaniumMangle.cpp
  lib/AST/StmtPrinter.cpp
  lib/AST/StmtProfile.cpp
  lib/CodeGen/CGExpr.cpp
  lib/CodeGen/CGExprAgg.cpp
  lib/CodeGen/CGExprComplex.cpp
  lib/CodeGen/CGExprScalar.cpp
  lib/CodeGen/CodeGenFunction.h
  lib/Parse/ParseExpr.cpp
  lib/Sema/SemaDeclCXX.cpp
  lib/Sema/SemaExceptionSpec.cpp
  lib/Sema/SemaExpr.cpp
  lib/Sema/TreeTransform.h
  lib/Serialization/ASTReaderStmt.cpp
  lib/Serialization/ASTWriterStmt.cpp
  lib/StaticAnalyzer/Core/ExprEngine.cpp
  test/CodeGenCXX/builtin_FUNCTION.cpp
  test/CodeGenCXX/builtin_LINE.cpp
  test/CodeGenCXX/debug-info-line.cpp
  test/Parser/builtin_source_location.c
  test/Sema/source_location.c
  test/SemaCXX/Inputs/source-location-file.h
  test/SemaCXX/source_location.cpp

Index: test/SemaCXX/source_location.cpp
===
--- /dev/null
+++ test/SemaCXX/source_location.cpp
@@ -0,0 +1,475 @@
+// RUN: %clang_cc1 -std=c++1z -fcxx-exceptions -fexceptions -verify %s
+// expected-no-diagnostics
+
+#define assert(...) ((__VA_ARGS__) ? ((void)0) : throw 42)
+#define CURRENT_FROM_MACRO() SL::current()
+#define FORWARD(...) __VA_ARGS__
+
+namespace std {
+namespace experimental {
+struct source_location {
+private:
+  unsigned int __m_line = 0;
+  unsigned int __m_col = 0;
+  const char *__m_file = nullptr;
+  const char *__m_func = nullptr;
+public:
+  static constexpr source_location current(
+  const char *__file = __builtin_FILE(),
+  const char *__func = __builtin_FUNCTION(),
+  unsigned int __line = __builtin_LINE(),
+  unsigned int __col = __builtin_COLUMN()) noexcept {
+source_location __loc;
+__loc.__m_line = __line;
+__loc.__m_col = __col;
+__loc.__m_file = __file;
+__loc.__m_func = __func;
+return __loc;
+  }
+  constexpr source_location() = default;
+  constexpr source_location(source_location const &) = default;
+  constexpr unsigned int line() const noexcept { return __m_line; }
+  constexpr unsigned int column() const noexcept { return __m_col; }
+  constexpr const char *file() const noexcept { return __m_file; }
+  constexpr const char *function() const noexcept { return __m_func; }
+};
+} // namespace experimental
+} // namespace std
+
+using SL = std::experimental::source_location;
+
+#include "Inputs/source-location-file.h"
+namespace SLF = source_location_file;
+
+constexpr bool is_equal(const char *LHS, const char *RHS) {
+  while (*LHS != 0 && *RHS != 0) {
+if (*LHS != *RHS)
+  return false;
+++LHS;
+++RHS;
+  }
+  return *LHS == 0 && *RHS == 0;
+}
+
+template 
+constexpr T identity(T t) {
+  return t;
+}
+
+template 
+struct Pair {
+  T first;
+  U second;
+};
+
+template 
+constexpr bool is_same = false;
+template 
+constexpr bool is_same = true;
+
+// test types
+static_assert(is_same);
+static_assert(is_same);
+static_assert(is_same);
+static_assert(is_same);
+
+// test noexcept
+static_assert(noexcept(__builtin_LINE()));
+static_assert(noexcept(__builtin_COLUMN()));
+static_assert(noexcept(__builtin_FILE()));
+static_assert(noexcept(__builtin_FUNCTION()));
+
+//===--===//
+//__builtin_LINE()
+//===--===//
+
+namespace test_line {
+
+static_assert(SL::current().line() == __LINE__);
+static_assert(SL::current().line() == CURRENT_FROM_MACRO().line());
+
+static constexpr SL GlobalS = SL::current();
+
+static_assert(GlobalS.line() == __LINE__ - 2);
+
+// clang-format off
+constexpr bool test_line_fn() {
+  constexpr SL S = SL::current();
+  static_assert(S.line() == (__LINE__ - 1), "");
+  // The start of the call expression to `current()` begins at the token `SL`
+  constexpr int ExpectLine = __LINE__ + 3;
+  constexpr SL S2
+  =
+  SL // Call expression starts here
+  ::
+  current
+  (
+
+  )
+  ;
+  static_assert(S2.line() == ExpectLine, "");
+
+  static_assert(
+  FORWARD(
+ __builtin_LINE
+(
+)
+  )
+== __LINE__ - 1, "");
+  static_assert(\
+\
+  __builtin_LINE()\
+\
+  == 

[PATCH] D42680: [ThinLTO] Ignore object files with no ThinLTO modules if -fthinlto-index= is set

2018-02-07 Thread Vitaly Buka via Phabricator via cfe-commits
vitalybuka added a comment.

ping


https://reviews.llvm.org/D42680



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


[libcxx] r324529 - Fix -verify static assert messages for older Clang versions

2018-02-07 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Wed Feb  7 13:25:25 2018
New Revision: 324529

URL: http://llvm.org/viewvc/llvm-project?rev=324529=rev
Log:
Fix -verify static assert messages for older Clang versions

Modified:
libcxx/trunk/test/std/containers/sequences/array/array.fill/fill.fail.cpp
libcxx/trunk/test/std/containers/sequences/array/array.swap/swap.fail.cpp

Modified: 
libcxx/trunk/test/std/containers/sequences/array/array.fill/fill.fail.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/sequences/array/array.fill/fill.fail.cpp?rev=324529=324528=324529=diff
==
--- libcxx/trunk/test/std/containers/sequences/array/array.fill/fill.fail.cpp 
(original)
+++ libcxx/trunk/test/std/containers/sequences/array/array.fill/fill.fail.cpp 
Wed Feb  7 13:25:25 2018
@@ -23,7 +23,7 @@ int main() {
 typedef double T;
 typedef std::array C;
 C c = {};
-// expected-error-re@array:* {{static_assert failed {{.*}} "cannot fill 
zero-sized array of type 'const T'"}}
+// expected-error-re@array:* {{static_assert failed {{.*}}"cannot fill 
zero-sized array of type 'const T'"}}
 c.fill(5.5); // expected-note {{requested here}}
   }
 }

Modified: 
libcxx/trunk/test/std/containers/sequences/array/array.swap/swap.fail.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/sequences/array/array.swap/swap.fail.cpp?rev=324529=324528=324529=diff
==
--- libcxx/trunk/test/std/containers/sequences/array/array.swap/swap.fail.cpp 
(original)
+++ libcxx/trunk/test/std/containers/sequences/array/array.swap/swap.fail.cpp 
Wed Feb  7 13:25:25 2018
@@ -24,7 +24,7 @@ int main() {
 typedef std::array C;
 C c = {};
 C c2 = {};
-// expected-error-re@array:* {{static_assert failed {{.*}} "cannot swap 
zero-sized array of type 'const T'"}}
+// expected-error-re@array:* {{static_assert failed {{.*}}"cannot swap 
zero-sized array of type 'const T'"}}
 c.swap(c2); // expected-note {{requested here}}
   }
 }


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


[PATCH] D40218: [Clang] Add __builtin_launder

2018-02-07 Thread Eric Fiselier via Phabricator via cfe-commits
EricWF updated this revision to Diff 133290.
EricWF added a comment.

- Rebase off master.


https://reviews.llvm.org/D40218

Files:
  include/clang/Basic/Builtins.def
  include/clang/Basic/DiagnosticSemaKinds.td
  lib/AST/ExprConstant.cpp
  lib/CodeGen/CGBuiltin.cpp
  lib/Sema/SemaChecking.cpp
  test/CodeGen/builtins.c
  test/CodeGenCXX/builtin-launder.cpp
  test/Preprocessor/feature_tests.c
  test/Sema/builtins.c
  test/SemaCXX/builtins.cpp

Index: test/SemaCXX/builtins.cpp
===
--- test/SemaCXX/builtins.cpp
+++ test/SemaCXX/builtins.cpp
@@ -53,3 +53,71 @@
 void synchronize_args() {
   __sync_synchronize(0); // expected-error {{too many arguments}}
 }
+
+namespace test_launder {
+
+struct Dummy {};
+
+using FnType = int(char);
+using MemFnType = int (Dummy::*)(char);
+using ConstMemFnType = int (Dummy::*)() const;
+
+void foo() {}
+
+void test_builtin_launder_diags(void *vp, const void *cvp, FnType *fnp,
+MemFnType mfp, ConstMemFnType cmfp) {
+  __builtin_launder(vp);   // expected-error {{void pointer argument to '__builtin_launder' is not allowed}}
+  __builtin_launder(cvp);  // expected-error {{void pointer argument to '__builtin_launder' is not allowed}}
+  __builtin_launder(fnp);  // expected-error {{function pointer argument to '__builtin_launder' is not allowed}}
+  __builtin_launder(mfp);  // expected-error {{non-pointer argument to '__builtin_launder' is not allowed}}
+  __builtin_launder(cmfp); // expected-error {{non-pointer argument to '__builtin_launder' is not allowed}}
+  (void)__builtin_launder();
+  __builtin_launder(42);  // expected-error {{non-pointer argument to '__builtin_launder' is not allowed}}
+  __builtin_launder(nullptr); // expected-error {{non-pointer argument to '__builtin_launder' is not allowed}}
+  __builtin_launder(foo)  // expected-error {{non-pointer argument to '__builtin_launder' is not allowed}}
+}
+
+void test_builtin_launder(char *p, const volatile int *ip, const float *,
+  double *__restrict dp) {
+  int x;
+  __builtin_launder(x); // expected-error {{non-pointer argument to '__builtin_launder' is not allowed}}
+#define TEST_TYPE(Ptr, Type) \
+  static_assert(__is_same(decltype(__builtin_launder(Ptr)), Type), "expected same type")
+  TEST_TYPE(p, char*);
+  TEST_TYPE(ip, const volatile int*);
+  TEST_TYPE(fp, const float*);
+  TEST_TYPE(dp, double *__restrict);
+#undef TEST_TYPE
+  char *d = __builtin_launder(p);
+  const volatile int *id = __builtin_launder(ip);
+  int *id2 = __builtin_launder(ip); // expected-error {{cannot initialize a variable of type 'int *' with an rvalue of type 'const volatile int *'}}
+  const float* fd = __builtin_launder(fp);
+}
+
+template 
+constexpr Tp *test_constexpr_launder(Tp *tp) {
+  return __builtin_launder(tp);
+}
+constexpr int const_int = 42;
+constexpr int const_int2 = 101;
+constexpr const int *const_ptr = test_constexpr_launder(_int);
+static_assert(_int == const_ptr, "");
+static_assert(const_ptr != test_constexpr_launder(_int2), "");
+
+void test_non_constexpr() {
+  constexpr int i = 42;// expected-note {{declared here}}
+  constexpr const int *ip = __builtin_launder(); // expected-error {{constexpr variable 'ip' must be initialized by a constant expression}}
+  // expected-note@-1 {{pointer to 'i' is not a constant expression}}
+}
+
+constexpr bool test_in_constexpr(const int ) {
+  return (__builtin_launder() == );
+}
+static_assert(test_in_constexpr(const_int), "");
+void f() {
+  constexpr int i = 42;
+  // FIXME: Should this work? Since `` doesn't.
+  static_assert(test_in_constexpr(i), "");
+}
+
+} // end namespace test_launder
Index: test/Sema/builtins.c
===
--- test/Sema/builtins.c
+++ test/Sema/builtins.c
@@ -248,3 +248,21 @@
 
 return buf;
 }
+
+typedef void (fn_t)(int);
+
+void test_builtin_launder(char *p, void *vp, const void *cvp,
+  const volatile int *ip, float *restrict fp,
+  fn_t *fn) {
+  __builtin_launder(); // expected-error {{too few arguments to function call, expected 1, have 0}}
+  __builtin_launder(p, p); // expected-error {{too many arguments to function call, expected 1, have 2}}
+  int x;
+  __builtin_launder(x); // expected-error {{non-pointer argument to '__builtin_launder' is not allowed}}
+  char *d = __builtin_launder(p);
+  __builtin_launder(vp);  // expected-error {{void pointer argument to '__builtin_launder' is not allowed}}
+  __builtin_launder(cvp); // expected-error {{void pointer argument to '__builtin_launder' is not allowed}}
+  const volatile int *id = __builtin_launder(ip);
+  int *id2 = __builtin_launder(ip); // expected-warning {{discards qualifiers}}
+  float *fd = __builtin_launder(fp);
+  __builtin_launder(fn); // expected-error {{function pointer argument to '__builtin_launder' is not allowed}}
+}

[PATCH] D43041: Add X86 Support to ValidCPUList (enabling march notes)

2018-02-07 Thread Erich Keane via Phabricator via cfe-commits
erichkeane created this revision.
erichkeane added reviewers: samparker, fhahn, rengolin, echristo, craig.topper.

A followup to: https://reviews.llvm.org/D42978
This patch adds X86 and X86_64 support for 
enabling the march notes.


Repository:
  rC Clang

https://reviews.llvm.org/D43041

Files:
  lib/Basic/Targets/X86.cpp
  lib/Basic/Targets/X86.h
  test/Misc/target-invalid-cpu-note.c


Index: test/Misc/target-invalid-cpu-note.c
===
--- test/Misc/target-invalid-cpu-note.c
+++ test/Misc/target-invalid-cpu-note.c
@@ -6,3 +6,11 @@
 // AARCH64: error: unknown target CPU 'not-a-cpu'
 // AARCH64: note: valid target CPU values are: cortex-a35, cortex-a53, 
cortex-a55, cortex-a57, cortex-a72, cortex-a73, cortex-a75, cyclone, exynos-m1, 
exynos-m2, exynos-m3, falkor, saphira, kryo, thunderx2t99, thunderx, 
thunderxt88, thunderxt81, thunderxt83
 
+// RUN: not %clang_cc1 -triple i386--- -target-cpu not-a-cpu -fsyntax-only %s 
2>&1 | FileCheck %s --check-prefix X86
+// X86: error: unknown target CPU 'not-a-cpu'
+// X86: note: valid target CPU values are: i386, i486, winchip-c6, winchip2, 
c3, i586, pentium, pentium-mmx, pentiumpro, i686, pentium2, pentium3, 
pentium3m, pentium-m, c3-2, yonah, pentium4, pentium4m, prescott, nocona, 
core2, penryn, bonnell, atom, silvermont, slm, goldmont, nehalem, corei7, 
westmere, sandybridge, corei7-avx, ivybridge, core-avx-i, haswell, core-avx2, 
broadwell, skylake, skylake-avx512, skx, cannonlake, icelake, knl, knm, 
lakemont, k6, k6-2, k6-3, athlon, athlon-tbird, athlon-xp, athlon-mp, athlon-4, 
k8, athlon64, athlon-fx, opteron, k8-sse3, athlon64-sse3, opteron-sse3, 
amdfam10, barcelona, btver1, btver2, bdver1, bdver2, bdver3, bdver4, znver1, 
x86-64, geode
+
+
+// RUN: not %clang_cc1 -triple x86_64--- -target-cpu not-a-cpu -fsyntax-only 
%s 2>&1 | FileCheck %s --check-prefix X86_64
+// X86_64: error: unknown target CPU 'not-a-cpu'
+// X86_64: note: valid target CPU values are: nocona, core2, penryn, bonnell, 
atom, silvermont, slm, goldmont, nehalem, corei7, westmere, sandybridge, 
corei7-avx, ivybridge, core-avx-i, haswell, core-avx2, broadwell, skylake, 
skylake-avx512, skx, cannonlake, icelake, knl, knm, k8, athlon64, athlon-fx, 
opteron, k8-sse3, athlon64-sse3, opteron-sse3, amdfam10, barcelona, btver1, 
btver2, bdver1, bdver2, bdver3, bdver4, znver1, x86-64
Index: lib/Basic/Targets/X86.h
===
--- lib/Basic/Targets/X86.h
+++ lib/Basic/Targets/X86.h
@@ -264,6 +264,8 @@
 return checkCPUKind(getCPUKind(Name));
   }
 
+  void fillValidCPUList(SmallVectorImpl ) const override;
+
   bool setCPU(const std::string ) override {
 return checkCPUKind(CPU = getCPUKind(Name));
   }
Index: lib/Basic/Targets/X86.cpp
===
--- lib/Basic/Targets/X86.cpp
+++ lib/Basic/Targets/X86.cpp
@@ -15,6 +15,7 @@
 #include "clang/Basic/Builtins.h"
 #include "clang/Basic/Diagnostic.h"
 #include "clang/Basic/TargetBuiltins.h"
+#include "llvm/ADT/StringExtras.h"
 #include "llvm/ADT/StringRef.h"
 #include "llvm/ADT/StringSwitch.h"
 #include "llvm/Support/TargetParser.h"
@@ -1648,8 +1649,6 @@
 bool X86TargetInfo::checkCPUKind(CPUKind Kind) const {
   // Perform any per-CPU checks necessary to determine if this CPU is
   // acceptable.
-  // FIXME: This results in terrible diagnostics. Clang just says the CPU is
-  // invalid without explaining *why*.
   switch (Kind) {
   case CK_Generic:
 // No processor selected!
@@ -1662,6 +1661,18 @@
   llvm_unreachable("Unhandled CPU kind");
 }
 
+void X86TargetInfo::fillValidCPUList(SmallVectorImpl ) const 
{
+#define PROC(ENUM, STRING, IS64BIT)
\
+  if (IS64BIT || getTriple().getArch() == llvm::Triple::x86)   
\
+Values.emplace_back(STRING);
+  // Go through CPUKind checking to ensure that the alias is de-aliased and 
+  // 64 bit-ness is checked.
+#define PROC_ALIAS(ENUM, ALIAS)
\
+  if (checkCPUKind(getCPUKind(ALIAS))) 
\
+Values.emplace_back(ALIAS);
+#include "clang/Basic/X86Target.def"
+}
+
 X86TargetInfo::CPUKind X86TargetInfo::getCPUKind(StringRef CPU) const {
   return llvm::StringSwitch(CPU)
 #define PROC(ENUM, STRING, IS64BIT) .Case(STRING, CK_##ENUM)


Index: test/Misc/target-invalid-cpu-note.c
===
--- test/Misc/target-invalid-cpu-note.c
+++ test/Misc/target-invalid-cpu-note.c
@@ -6,3 +6,11 @@
 // AARCH64: error: unknown target CPU 'not-a-cpu'
 // AARCH64: note: valid target CPU values are: cortex-a35, cortex-a53, cortex-a55, cortex-a57, cortex-a72, cortex-a73, cortex-a75, cyclone, exynos-m1, exynos-m2, exynos-m3, falkor, saphira, kryo, thunderx2t99, thunderx, thunderxt88, thunderxt81, thunderxt83
 
+// RUN: not %clang_cc1 -triple i386--- 

r324527 - [clang-import-test] Run clang-format, NFC

2018-02-07 Thread Vedant Kumar via cfe-commits
Author: vedantk
Date: Wed Feb  7 13:17:22 2018
New Revision: 324527

URL: http://llvm.org/viewvc/llvm-project?rev=324527=rev
Log:
[clang-import-test] Run clang-format, NFC

I ran across clang-import-test while looking into testing for lldb.
There shouldn't be any harm in running clang-format over it.

Modified:
cfe/trunk/tools/clang-import-test/clang-import-test.cpp

Modified: cfe/trunk/tools/clang-import-test/clang-import-test.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/clang-import-test/clang-import-test.cpp?rev=324527=324526=324527=diff
==
--- cfe/trunk/tools/clang-import-test/clang-import-test.cpp (original)
+++ cfe/trunk/tools/clang-import-test/clang-import-test.cpp Wed Feb  7 13:17:22 
2018
@@ -50,9 +50,10 @@ static llvm::cl::opt
 Direct("direct", llvm::cl::Optional,
llvm::cl::desc("Use the parsed declarations without indirection"));
 
-static llvm::cl::opt
-UseOrigins("use-origins", llvm::cl::Optional,
-   llvm::cl::desc("Use DeclContext origin information for more 
accurate lookups"));  
+static llvm::cl::opt UseOrigins(
+"use-origins", llvm::cl::Optional,
+llvm::cl::desc(
+"Use DeclContext origin information for more accurate lookups"));
 
 static llvm::cl::list
 ClangArgs("Xcc", llvm::cl::ZeroOrMore,
@@ -225,7 +226,7 @@ std::unique_ptr BuildCode
   CI.getDiagnostics(), ModuleName, CI.getHeaderSearchOpts(),
   CI.getPreprocessorOpts(), CI.getCodeGenOpts(), LLVMCtx));
 }
-} // end namespace
+} // namespace init_convenience
 
 namespace {
 
@@ -261,8 +262,8 @@ void AddExternalSource(CIAndOrigins ,
   {CI.getASTContext(), CI.getFileManager()});
   llvm::SmallVector Sources;
   for (CIAndOrigins  : Imports)
-Sources.push_back(
-{Import.getASTContext(), Import.getFileManager(), 
Import.getOriginMap()});
+Sources.push_back({Import.getASTContext(), Import.getFileManager(),
+   Import.getOriginMap()});
   auto ES = llvm::make_unique(Target, Sources);
   CI.getASTContext().setExternalSource(ES.release());
   CI.getASTContext().getTranslationUnitDecl()->setHasExternalVisibleStorage();
@@ -334,8 +335,8 @@ llvm::Expected Parse(const
 void Forget(CIAndOrigins , llvm::MutableArrayRef Imports) {
   llvm::SmallVector Sources;
   for (CIAndOrigins  : Imports)
-Sources.push_back(
-{Import.getASTContext(), Import.getFileManager(), 
Import.getOriginMap()});
+Sources.push_back({Import.getASTContext(), Import.getFileManager(),
+   Import.getOriginMap()});
   ExternalASTSource *Source = CI.CI->getASTContext().getExternalSource();
   auto *Merger = static_cast(Source);
   Merger->RemoveSources(Sources);


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


[PATCH] D40218: [Clang] Add __builtin_launder

2018-02-07 Thread Eric Fiselier via Phabricator via cfe-commits
EricWF added a comment.

Ping.


https://reviews.llvm.org/D40218



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


[PATCH] D41223: [libc++] Fix PR35491 - std::array of zero-size doesn't work with non-default constructible types.

2018-02-07 Thread Eric Fiselier via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL324526: [libc++] Fix PR35491 - std::array of zero-size 
doesnt work with non-default… (authored by EricWF, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D41223?vs=133285=133288#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D41223

Files:
  libcxx/trunk/include/__config
  libcxx/trunk/include/array
  
libcxx/trunk/test/libcxx/containers/sequences/array/array.zero/db_back.pass.cpp
  
libcxx/trunk/test/libcxx/containers/sequences/array/array.zero/db_front.pass.cpp
  
libcxx/trunk/test/libcxx/containers/sequences/array/array.zero/db_indexing.pass.cpp
  libcxx/trunk/test/std/containers/sequences/array/array.cons/default.pass.cpp
  
libcxx/trunk/test/std/containers/sequences/array/array.cons/implicit_copy.pass.cpp
  libcxx/trunk/test/std/containers/sequences/array/array.data/data.pass.cpp
  
libcxx/trunk/test/std/containers/sequences/array/array.data/data_const.pass.cpp
  libcxx/trunk/test/std/containers/sequences/array/array.fill/fill.fail.cpp
  libcxx/trunk/test/std/containers/sequences/array/array.swap/swap.fail.cpp
  libcxx/trunk/test/std/containers/sequences/array/at.pass.cpp
  libcxx/trunk/test/std/containers/sequences/array/begin.pass.cpp
  libcxx/trunk/test/std/containers/sequences/array/compare.fail.cpp
  libcxx/trunk/test/std/containers/sequences/array/compare.pass.cpp
  libcxx/trunk/test/std/containers/sequences/array/empty.fail.cpp
  libcxx/trunk/test/std/containers/sequences/array/front_back.pass.cpp
  libcxx/trunk/test/std/containers/sequences/array/indexing.pass.cpp
  libcxx/trunk/test/std/containers/sequences/array/size_and_alignment.pass.cpp

Index: libcxx/trunk/include/__config
===
--- libcxx/trunk/include/__config
+++ libcxx/trunk/include/__config
@@ -793,8 +793,13 @@
 # if !defined(_LIBCPP_DEBUG)
 #   error cannot use _LIBCPP_DEBUG_USE_EXCEPTIONS unless _LIBCPP_DEBUG is defined
 # endif
-# define _NOEXCEPT_DEBUG noexcept(false)
-# define _NOEXCEPT_DEBUG_(x) noexcept(false)
+# ifdef _LIBCPP_HAS_NO_NOEXCEPT
+#   define _NOEXCEPT_DEBUG
+#   define _NOEXCEPT_DEBUG_(x)
+# else
+#   define _NOEXCEPT_DEBUG noexcept(false)
+#   define _NOEXCEPT_DEBUG_(x) noexcept(false)
+#endif
 #else
 # define _NOEXCEPT_DEBUG _NOEXCEPT
 # define _NOEXCEPT_DEBUG_(x) _NOEXCEPT_(x)
Index: libcxx/trunk/include/array
===
--- libcxx/trunk/include/array
+++ libcxx/trunk/include/array
@@ -108,6 +108,8 @@
 #include 
 #include 
 #include 
+#include  // for _LIBCPP_UNREACHABLE
+#include <__debug>
 
 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
 #pragma GCC system_header
@@ -117,6 +119,7 @@
 
 _LIBCPP_BEGIN_NAMESPACE_STD
 
+
 template 
 struct _LIBCPP_TEMPLATE_VIS array
 {
@@ -134,31 +137,27 @@
 typedef std::reverse_iterator   reverse_iterator;
 typedef std::reverse_iterator const_reverse_iterator;
 
-value_type __elems_[_Size > 0 ? _Size : 1];
+_Tp __elems_[_Size];
 
 // No explicit construct/copy/destroy for aggregate type
-_LIBCPP_INLINE_VISIBILITY void fill(const value_type& __u)
-{_VSTD::fill_n(__elems_, _Size, __u);}
-_LIBCPP_INLINE_VISIBILITY
-void swap(array& __a) _NOEXCEPT_(_Size == 0 || __is_nothrow_swappable<_Tp>::value)
-{ __swap_dispatch((std::integral_constant()), __a); }
+_LIBCPP_INLINE_VISIBILITY void fill(const value_type& __u) {
+  _VSTD::fill_n(__elems_, _Size, __u);
+}
 
 _LIBCPP_INLINE_VISIBILITY
-void __swap_dispatch(std::true_type, array&) {}
-
-_LIBCPP_INLINE_VISIBILITY
-void __swap_dispatch(std::false_type, array& __a)
-{ _VSTD::swap_ranges(__elems_, __elems_ + _Size, __a.__elems_);}
+void swap(array& __a) _NOEXCEPT_(__is_nothrow_swappable<_Tp>::value) {
+  std::swap_ranges(__elems_, __elems_ + _Size, __a.__elems_);
+}
 
 // iterators:
 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
-iterator begin() _NOEXCEPT {return iterator(__elems_);}
+iterator begin() _NOEXCEPT {return iterator(data());}
 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
-const_iterator begin() const _NOEXCEPT {return const_iterator(__elems_);}
+const_iterator begin() const _NOEXCEPT {return const_iterator(data());}
 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
-iterator end() _NOEXCEPT {return iterator(__elems_ + _Size);}
+iterator end() _NOEXCEPT {return iterator(data() + _Size);}
 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
-const_iterator end() const _NOEXCEPT {return const_iterator(__elems_ + _Size);}
+const_iterator end() const _NOEXCEPT {return const_iterator(data() + _Size);}
 
 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
 reverse_iterator rbegin() _NOEXCEPT {return reverse_iterator(end());}
@@ -184,7 +183,7 

[PATCH] D41223: [libc++] Fix PR35491 - std::array of zero-size doesn't work with non-default constructible types.

2018-02-07 Thread Eric Fiselier via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rCXX324526: [libc++] Fix PR35491 - std::array of zero-size 
doesnt work with non-default… (authored by EricWF, committed by ).

Repository:
  rCXX libc++

https://reviews.llvm.org/D41223

Files:
  include/__config
  include/array
  test/libcxx/containers/sequences/array/array.zero/db_back.pass.cpp
  test/libcxx/containers/sequences/array/array.zero/db_front.pass.cpp
  test/libcxx/containers/sequences/array/array.zero/db_indexing.pass.cpp
  test/std/containers/sequences/array/array.cons/default.pass.cpp
  test/std/containers/sequences/array/array.cons/implicit_copy.pass.cpp
  test/std/containers/sequences/array/array.data/data.pass.cpp
  test/std/containers/sequences/array/array.data/data_const.pass.cpp
  test/std/containers/sequences/array/array.fill/fill.fail.cpp
  test/std/containers/sequences/array/array.swap/swap.fail.cpp
  test/std/containers/sequences/array/at.pass.cpp
  test/std/containers/sequences/array/begin.pass.cpp
  test/std/containers/sequences/array/compare.fail.cpp
  test/std/containers/sequences/array/compare.pass.cpp
  test/std/containers/sequences/array/empty.fail.cpp
  test/std/containers/sequences/array/front_back.pass.cpp
  test/std/containers/sequences/array/indexing.pass.cpp
  test/std/containers/sequences/array/size_and_alignment.pass.cpp

Index: include/array
===
--- include/array
+++ include/array
@@ -108,6 +108,8 @@
 #include 
 #include 
 #include 
+#include  // for _LIBCPP_UNREACHABLE
+#include <__debug>
 
 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
 #pragma GCC system_header
@@ -117,6 +119,7 @@
 
 _LIBCPP_BEGIN_NAMESPACE_STD
 
+
 template 
 struct _LIBCPP_TEMPLATE_VIS array
 {
@@ -134,31 +137,27 @@
 typedef std::reverse_iterator   reverse_iterator;
 typedef std::reverse_iterator const_reverse_iterator;
 
-value_type __elems_[_Size > 0 ? _Size : 1];
+_Tp __elems_[_Size];
 
 // No explicit construct/copy/destroy for aggregate type
-_LIBCPP_INLINE_VISIBILITY void fill(const value_type& __u)
-{_VSTD::fill_n(__elems_, _Size, __u);}
-_LIBCPP_INLINE_VISIBILITY
-void swap(array& __a) _NOEXCEPT_(_Size == 0 || __is_nothrow_swappable<_Tp>::value)
-{ __swap_dispatch((std::integral_constant()), __a); }
+_LIBCPP_INLINE_VISIBILITY void fill(const value_type& __u) {
+  _VSTD::fill_n(__elems_, _Size, __u);
+}
 
 _LIBCPP_INLINE_VISIBILITY
-void __swap_dispatch(std::true_type, array&) {}
-
-_LIBCPP_INLINE_VISIBILITY
-void __swap_dispatch(std::false_type, array& __a)
-{ _VSTD::swap_ranges(__elems_, __elems_ + _Size, __a.__elems_);}
+void swap(array& __a) _NOEXCEPT_(__is_nothrow_swappable<_Tp>::value) {
+  std::swap_ranges(__elems_, __elems_ + _Size, __a.__elems_);
+}
 
 // iterators:
 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
-iterator begin() _NOEXCEPT {return iterator(__elems_);}
+iterator begin() _NOEXCEPT {return iterator(data());}
 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
-const_iterator begin() const _NOEXCEPT {return const_iterator(__elems_);}
+const_iterator begin() const _NOEXCEPT {return const_iterator(data());}
 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
-iterator end() _NOEXCEPT {return iterator(__elems_ + _Size);}
+iterator end() _NOEXCEPT {return iterator(data() + _Size);}
 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
-const_iterator end() const _NOEXCEPT {return const_iterator(__elems_ + _Size);}
+const_iterator end() const _NOEXCEPT {return const_iterator(data() + _Size);}
 
 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
 reverse_iterator rbegin() _NOEXCEPT {return reverse_iterator(end());}
@@ -184,7 +183,7 @@
 _LIBCPP_INLINE_VISIBILITY
 _LIBCPP_CONSTEXPR size_type max_size() const _NOEXCEPT {return _Size;}
 _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
-_LIBCPP_CONSTEXPR bool empty() const _NOEXCEPT {return _Size == 0;}
+_LIBCPP_CONSTEXPR bool empty() const _NOEXCEPT {return false; }
 
 // element access:
 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
@@ -197,15 +196,16 @@
 
 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 reference front() {return __elems_[0];}
 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 const_reference front() const {return __elems_[0];}
-_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 reference back()  {return __elems_[_Size > 0 ? _Size-1 : 0];}
-_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 const_reference back() const  {return __elems_[_Size > 0 ? _Size-1 : 0];}
+_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 reference back()  {return __elems_[_Size - 1];}
+_LIBCPP_INLINE_VISIBILITY 

[PATCH] D41223: [libc++] Fix PR35491 - std::array of zero-size doesn't work with non-default constructible types.

2018-02-07 Thread Eric Fiselier via Phabricator via cfe-commits
EricWF accepted this revision.
EricWF added a comment.

Accepting new version.


https://reviews.llvm.org/D41223



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


[libcxx] r324526 - [libc++] Fix PR35491 - std::array of zero-size doesn't work with non-default constructible types.

2018-02-07 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Wed Feb  7 13:06:13 2018
New Revision: 324526

URL: http://llvm.org/viewvc/llvm-project?rev=324526=rev
Log:
[libc++] Fix PR35491 - std::array of zero-size doesn't work with non-default 
constructible types.

Summary:
This patch fixes llvm.org/PR35491 and LWG2157  
(https://cplusplus.github.io/LWG/issue2157)

The fix attempts to maintain ABI compatibility by replacing the array with a 
instance of `aligned_storage`.

Reviewers: mclow.lists, EricWF

Reviewed By: EricWF

Subscribers: lichray, cfe-commits

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

Added:
libcxx/trunk/test/libcxx/containers/sequences/array/array.zero/

libcxx/trunk/test/libcxx/containers/sequences/array/array.zero/db_back.pass.cpp

libcxx/trunk/test/libcxx/containers/sequences/array/array.zero/db_front.pass.cpp

libcxx/trunk/test/libcxx/containers/sequences/array/array.zero/db_indexing.pass.cpp

libcxx/trunk/test/std/containers/sequences/array/array.cons/implicit_copy.pass.cpp
libcxx/trunk/test/std/containers/sequences/array/array.fill/fill.fail.cpp
libcxx/trunk/test/std/containers/sequences/array/array.swap/swap.fail.cpp
libcxx/trunk/test/std/containers/sequences/array/compare.fail.cpp
libcxx/trunk/test/std/containers/sequences/array/compare.pass.cpp
libcxx/trunk/test/std/containers/sequences/array/size_and_alignment.pass.cpp
Modified:
libcxx/trunk/include/__config
libcxx/trunk/include/array
libcxx/trunk/test/std/containers/sequences/array/array.cons/default.pass.cpp
libcxx/trunk/test/std/containers/sequences/array/array.data/data.pass.cpp

libcxx/trunk/test/std/containers/sequences/array/array.data/data_const.pass.cpp
libcxx/trunk/test/std/containers/sequences/array/at.pass.cpp
libcxx/trunk/test/std/containers/sequences/array/begin.pass.cpp
libcxx/trunk/test/std/containers/sequences/array/empty.fail.cpp
libcxx/trunk/test/std/containers/sequences/array/front_back.pass.cpp
libcxx/trunk/test/std/containers/sequences/array/indexing.pass.cpp

Modified: libcxx/trunk/include/__config
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/__config?rev=324526=324525=324526=diff
==
--- libcxx/trunk/include/__config (original)
+++ libcxx/trunk/include/__config Wed Feb  7 13:06:13 2018
@@ -793,8 +793,13 @@ namespace std {
 # if !defined(_LIBCPP_DEBUG)
 #   error cannot use _LIBCPP_DEBUG_USE_EXCEPTIONS unless _LIBCPP_DEBUG is 
defined
 # endif
-# define _NOEXCEPT_DEBUG noexcept(false)
-# define _NOEXCEPT_DEBUG_(x) noexcept(false)
+# ifdef _LIBCPP_HAS_NO_NOEXCEPT
+#   define _NOEXCEPT_DEBUG
+#   define _NOEXCEPT_DEBUG_(x)
+# else
+#   define _NOEXCEPT_DEBUG noexcept(false)
+#   define _NOEXCEPT_DEBUG_(x) noexcept(false)
+#endif
 #else
 # define _NOEXCEPT_DEBUG _NOEXCEPT
 # define _NOEXCEPT_DEBUG_(x) _NOEXCEPT_(x)

Modified: libcxx/trunk/include/array
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/array?rev=324526=324525=324526=diff
==
--- libcxx/trunk/include/array (original)
+++ libcxx/trunk/include/array Wed Feb  7 13:06:13 2018
@@ -108,6 +108,8 @@ template  c
 #include 
 #include 
 #include 
+#include  // for _LIBCPP_UNREACHABLE
+#include <__debug>
 
 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
 #pragma GCC system_header
@@ -117,6 +119,7 @@ template  c
 
 _LIBCPP_BEGIN_NAMESPACE_STD
 
+
 template 
 struct _LIBCPP_TEMPLATE_VIS array
 {
@@ -134,31 +137,27 @@ struct _LIBCPP_TEMPLATE_VIS array
 typedef std::reverse_iterator   reverse_iterator;
 typedef std::reverse_iterator const_reverse_iterator;
 
-value_type __elems_[_Size > 0 ? _Size : 1];
+_Tp __elems_[_Size];
 
 // No explicit construct/copy/destroy for aggregate type
-_LIBCPP_INLINE_VISIBILITY void fill(const value_type& __u)
-{_VSTD::fill_n(__elems_, _Size, __u);}
-_LIBCPP_INLINE_VISIBILITY
-void swap(array& __a) _NOEXCEPT_(_Size == 0 || 
__is_nothrow_swappable<_Tp>::value)
-{ __swap_dispatch((std::integral_constant()), __a); }
+_LIBCPP_INLINE_VISIBILITY void fill(const value_type& __u) {
+  _VSTD::fill_n(__elems_, _Size, __u);
+}
 
 _LIBCPP_INLINE_VISIBILITY
-void __swap_dispatch(std::true_type, array&) {}
-
-_LIBCPP_INLINE_VISIBILITY
-void __swap_dispatch(std::false_type, array& __a)
-{ _VSTD::swap_ranges(__elems_, __elems_ + _Size, __a.__elems_);}
+void swap(array& __a) _NOEXCEPT_(__is_nothrow_swappable<_Tp>::value) {
+  std::swap_ranges(__elems_, __elems_ + _Size, __a.__elems_);
+}
 
 // iterators:
 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
-iterator begin() _NOEXCEPT {return iterator(__elems_);}
+iterator begin() _NOEXCEPT {return iterator(data());}
 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
-const_iterator begin() const _NOEXCEPT 

[PATCH] D41223: [libc++] Fix PR35491 - std::array of zero-size doesn't work with non-default constructible types.

2018-02-07 Thread Eric Fiselier via Phabricator via cfe-commits
EricWF updated this revision to Diff 133285.
EricWF added a comment.

- Update with new, hopefully working, version.


https://reviews.llvm.org/D41223

Files:
  include/__config
  include/array
  test/libcxx/containers/sequences/array/array.zero/db_back.pass.cpp
  test/libcxx/containers/sequences/array/array.zero/db_front.pass.cpp
  test/libcxx/containers/sequences/array/array.zero/db_indexing.pass.cpp
  test/std/containers/sequences/array/array.cons/default.pass.cpp
  test/std/containers/sequences/array/array.cons/implicit_copy.pass.cpp
  test/std/containers/sequences/array/array.data/data.pass.cpp
  test/std/containers/sequences/array/array.data/data_const.pass.cpp
  test/std/containers/sequences/array/array.fill/fill.fail.cpp
  test/std/containers/sequences/array/array.swap/swap.fail.cpp
  test/std/containers/sequences/array/at.pass.cpp
  test/std/containers/sequences/array/begin.pass.cpp
  test/std/containers/sequences/array/compare.fail.cpp
  test/std/containers/sequences/array/compare.pass.cpp
  test/std/containers/sequences/array/empty.fail.cpp
  test/std/containers/sequences/array/front_back.pass.cpp
  test/std/containers/sequences/array/indexing.pass.cpp
  test/std/containers/sequences/array/size_and_alignment.pass.cpp

Index: test/std/containers/sequences/array/size_and_alignment.pass.cpp
===
--- /dev/null
+++ test/std/containers/sequences/array/size_and_alignment.pass.cpp
@@ -0,0 +1,55 @@
+//===--===//
+//
+// 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.
+//
+//===--===//
+
+// 
+
+// template 
+// struct array
+
+// Test the size and alignment matches that of an array of a given type.
+
+#include 
+#include 
+#include 
+#include 
+
+#include "test_macros.h"
+
+template 
+void test() {
+  typedef T CArrayT[Size == 0 ? 1 : Size];
+  typedef std::array ArrayT;
+  static_assert(sizeof(CArrayT) == sizeof(ArrayT), "");
+  static_assert(TEST_ALIGNOF(CArrayT) == TEST_ALIGNOF(ArrayT), "");
+}
+
+template 
+void test_type() {
+  test();
+  test();
+  test();
+}
+
+struct TEST_ALIGNAS(TEST_ALIGNOF(std::max_align_t) * 2) TestType1 {
+
+};
+
+struct TEST_ALIGNAS(TEST_ALIGNOF(std::max_align_t) * 2) TestType2 {
+  char data[1000];
+};
+
+int main() {
+  test_type();
+  test_type();
+  test_type();
+  test_type();
+  test_type();
+  test_type();
+  test_type();
+}
Index: test/std/containers/sequences/array/indexing.pass.cpp
===
--- test/std/containers/sequences/array/indexing.pass.cpp
+++ test/std/containers/sequences/array/indexing.pass.cpp
@@ -56,7 +56,34 @@
 C::const_reference r2 = c[2];
 assert(r2 == 3.5);
 }
-
+{ // Test operator[] "works" on zero sized arrays
+typedef double T;
+typedef std::array C;
+C c = {};
+C const& cc = c;
+static_assert((std::is_same::value), "");
+static_assert((std::is_same::value), "");
+if (c.size() > (0)) { // always false
+  C::reference r1 = c[0];
+  C::const_reference r2 = cc[0];
+  ((void)r1);
+  ((void)r2);
+}
+}
+{ // Test operator[] "works" on zero sized arrays
+typedef double T;
+typedef std::array C;
+C c = {{}};
+C const& cc = c;
+static_assert((std::is_same::value), "");
+static_assert((std::is_same::value), "");
+if (c.size() > (0)) { // always false
+  C::reference r1 = c[0];
+  C::const_reference r2 = cc[0];
+  ((void)r1);
+  ((void)r2);
+}
+}
 #if TEST_STD_VER > 11
 {
 typedef double T;
Index: test/std/containers/sequences/array/front_back.pass.cpp
===
--- test/std/containers/sequences/array/front_back.pass.cpp
+++ test/std/containers/sequences/array/front_back.pass.cpp
@@ -64,7 +64,38 @@
 C::const_reference r2 = c.back();
 assert(r2 == 3.5);
 }
-
+{
+  typedef double T;
+  typedef std::array C;
+  C c = {};
+  C const& cc = c;
+  static_assert((std::is_same::value), "");
+  static_assert((std::is_same::value), "");
+  static_assert((std::is_same::value), "");
+  static_assert((std::is_same::value), "");
+  if (c.size() > (0)) { // always false
+TEST_IGNORE_NODISCARD c.front();
+TEST_IGNORE_NODISCARD c.back();
+

[PATCH] D41223: [libc++] Fix PR35491 - std::array of zero-size doesn't work with non-default constructible types.

2018-02-07 Thread Eric Fiselier via Phabricator via cfe-commits
EricWF reopened this revision.
EricWF added a comment.
This revision is now accepted and ready to land.

This was reverted as it caused build failures. Re-opening with new version.


Repository:
  rCXX libc++

https://reviews.llvm.org/D41223



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


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

2018-02-07 Thread Russell McClellan via Phabricator via cfe-commits
russellmcc added a comment.

Thanks for the feedback!  I'm very motivated to get some support for these 
features since they are required for my style guide.  Let me know if my recent 
changes made sense to you.




Comment at: lib/Format/ContinuationIndenter.cpp:756
  State.Line->MustBeDeclaration) ||
-Previous.is(TT_DictLiteral))
+Previous.is(TT_DictLiteral) || !Style.AllowAllArgumentsOnNextLine)
   State.Stack.back().BreakBeforeParameter = true;

djasper wrote:
> Hm, this looks suspicious. Doesn't this mean that AllowAllArgumentsOnNextLine 
> implies/overwrites AllowAllParametersOfDeclarationOnNextLine?
> 
> Now, there are two ways out of this:
> - Fix it
> - Provide different options
> 
> The question is whether someone would ever want AllowAllArgumentsOnNextLine 
> to be false while AllowAllParametersOfDeclarationOnNextLine is true. That 
> would seem weird to me. If not, it might be better to turn the existing 
> option into an enum with three values (None, Declarations, All) or something.
Oops!  Thanks for finding this.  I think since other options are exposed 
separately for parameters and arguments (e.g., bin packing), it's more 
consistent to break these out separately.



Comment at: lib/Format/ContinuationIndenter.cpp:962
 State.Stack.back().NestedBlockIndent = State.Stack.back().Indent;
-if (Style.ConstructorInitializerAllOnOneLineOrOnePerLine)
+if (Style.ConstructorInitializerAllOnOneLineOrOnePerLine) {
   State.Stack.back().AvoidBinPacking = true;

djasper wrote:
> I am not 100%, but I think this is doing too much. In accordance with the 
> other options, this should still allow:
> 
>   Constructor() : a(a), b(b) {}
> 
> so long as everything fits on one line (and I think it might not). Either 
> way, add a test.
I think the case you're talking about actually works; I've added a test.



Comment at: lib/Format/Format.cpp:748
   } else {
+ChromiumStyle.AllowAllArgumentsOnNextLine = true;
+ChromiumStyle.AllowAllConstructorInitializersOnNextLine = true;

djasper wrote:
> I think there is no need to set these here and below. Everything derives from 
> LLVM style.
Removed!



Comment at: unittests/Format/FormatTest.cpp:3440
+  Style.ColumnLimit = 60;
+  Style.ConstructorInitializerAllOnOneLineOrOnePerLine = true;
+  Style.AllowAllConstructorInitializersOnNextLine = true;

djasper wrote:
> If we go forward with this, the name of this option gets really confusing and 
> we need to think about renaming it. Or maybe we can also turn it into an enum 
> with three values?
> 
> Here also, the combination of
>   ConstructorInitializerAllOnOneLineOrOnePerLine=false and 
>   AllowAllConstructorInitializersOnNextLine=true
> seems really weird. I wouldn't even know what the desired behavior is in that 
> case.
I agree this combination is weird, however the situation already existed with 
declaration parameters (i.e., `AllowAllParametersOfDeclarationOnNextLine` has 
no effect when `BinPackParameters` was true).  I think exposing these new 
parameters in this way is the most consistent with the existing approach.

I've edited the doc comment for `AllowAllConstructorInitializersOnNextLine ` to 
note that it has no effect when 
`ConstructorInitializerAllOnOneLineOrOnePerLine` is false.



https://reviews.llvm.org/D40988



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


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

2018-02-07 Thread Russell McClellan via Phabricator via cfe-commits
russellmcc updated this revision to Diff 133280.
russellmcc added a comment.

Responded to review feedback:

- Fix bug where `AllowAllArgumentsOnNextLine` overrode 
`AllowAllParametersOfDeclarationOnNextLine`
- Add tests demonstrating independence of `AllowAllArgumentsOnNextLine` and 
`AllowAllParametersOfDeclarationOnNextLine`
- Add test showing `AllowAllConstructorInitializersOnNextLine` doesn't affect 
single-line constructors
- Removed unnecessary re-setting of llvm styles
- Removed bonus line from test


https://reviews.llvm.org/D40988

Files:
  include/clang/Format/Format.h
  lib/Format/ContinuationIndenter.cpp
  lib/Format/Format.cpp
  unittests/Format/FormatTest.cpp

Index: unittests/Format/FormatTest.cpp
===
--- unittests/Format/FormatTest.cpp
+++ unittests/Format/FormatTest.cpp
@@ -3433,6 +3433,56 @@
"() {}"));
 }
 
+TEST_F(FormatTest, AllowAllConstructorInitializersOnNextLine) {
+  FormatStyle Style = getLLVMStyle();
+  Style.BreakConstructorInitializers = FormatStyle::BCIS_BeforeComma;
+  Style.ColumnLimit = 60;
+  Style.ConstructorInitializerAllOnOneLineOrOnePerLine = true;
+  Style.AllowAllConstructorInitializersOnNextLine = true;
+  verifyFormat("Constructor()\n"
+   ": (a), b(b) {}",
+   Style);
+  verifyFormat("Constructor() : a(a), b(b) {}", Style);
+
+  Style.AllowAllConstructorInitializersOnNextLine = false;
+  verifyFormat("Constructor()\n"
+   ": (a)\n"
+   ", b(b) {}",
+   Style);
+  verifyFormat("Constructor() : a(a), b(b) {}", Style);
+}
+
+TEST_F(FormatTest, AllowAllArgumentsOnNextLine) {
+  FormatStyle Style = getLLVMStyle();
+  Style.ColumnLimit = 60;
+  Style.BinPackArguments = false;
+  Style.AllowAllArgumentsOnNextLine = true;
+  verifyFormat("void foo() {\n"
+   "  FunctionCallWithReallyLongName(\n"
+   "  aaa, );\n"
+   "}",
+   Style);
+  Style.AllowAllArgumentsOnNextLine = false;
+  verifyFormat("void foo() {\n"
+   "  FunctionCallWithReallyLongName(\n"
+   "  aaa,\n"
+   "  );\n"
+   "}",
+   Style);
+
+  // This parameter should not affect declarations.
+  Style.BinPackParameters = false;
+  Style.AllowAllParametersOfDeclarationOnNextLine = true;
+  verifyFormat("void FunctionCallWithReallyLongName(\n"
+   "int aaa, int );",
+   Style);
+  Style.AllowAllParametersOfDeclarationOnNextLine = false;
+  verifyFormat("void FunctionCallWithReallyLongName(\n"
+   "int aaa,\n"
+   "int );",
+   Style);
+}
+
 TEST_F(FormatTest, BreakConstructorInitializersAfterColon) {
   FormatStyle Style = getLLVMStyle();
   Style.BreakConstructorInitializers = FormatStyle::BCIS_AfterColon;
@@ -10020,6 +10070,8 @@
   CHECK_PARSE_BOOL(AlignTrailingComments);
   CHECK_PARSE_BOOL(AlignConsecutiveAssignments);
   CHECK_PARSE_BOOL(AlignConsecutiveDeclarations);
+  CHECK_PARSE_BOOL(AllowAllArgumentsOnNextLine);
+  CHECK_PARSE_BOOL(AllowAllConstructorInitializersOnNextLine);
   CHECK_PARSE_BOOL(AllowAllParametersOfDeclarationOnNextLine);
   CHECK_PARSE_BOOL(AllowShortBlocksOnASingleLine);
   CHECK_PARSE_BOOL(AllowShortCaseLabelsOnASingleLine);
Index: lib/Format/Format.cpp
===
--- lib/Format/Format.cpp
+++ lib/Format/Format.cpp
@@ -287,6 +287,10 @@
 IO.mapOptional("AlignEscapedNewlines", Style.AlignEscapedNewlines);
 IO.mapOptional("AlignOperands", Style.AlignOperands);
 IO.mapOptional("AlignTrailingComments", Style.AlignTrailingComments);
+IO.mapOptional("AllowAllArgumentsOnNextLine",
+   Style.AllowAllArgumentsOnNextLine);
+IO.mapOptional("AllowAllConstructorInitializersOnNextLine",
+   Style.AllowAllConstructorInitializersOnNextLine);
 IO.mapOptional("AllowAllParametersOfDeclarationOnNextLine",
Style.AllowAllParametersOfDeclarationOnNextLine);
 IO.mapOptional("AllowShortBlocksOnASingleLine",
@@ -303,6 +307,7 @@
Style.AlwaysBreakAfterDefinitionReturnType);
 IO.mapOptional("AlwaysBreakAfterReturnType",
Style.AlwaysBreakAfterReturnType);
+
 // If AlwaysBreakAfterDefinitionReturnType was specified but
 // AlwaysBreakAfterReturnType was not, initialize the latter from the
 // former for backwards compatibility.
@@ -575,6 +580,8 @@
   LLVMStyle.AlignTrailingComments = true;
   LLVMStyle.AlignConsecutiveAssignments = false;
   LLVMStyle.AlignConsecutiveDeclarations = false;
+  LLVMStyle.AllowAllArgumentsOnNextLine = true;
+  

[PATCH] D42561: [PR36008] Avoid -Wsign-compare warning for enum constants in typeof expressions

2018-02-07 Thread Alex Lorenz via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL324514: [PR36008] Avoid -Wsign-compare warning for enum 
constants in (authored by arphaman, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D42561?vs=132901=133281#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D42561

Files:
  cfe/trunk/lib/Sema/SemaChecking.cpp
  cfe/trunk/test/Sema/compare.c


Index: cfe/trunk/lib/Sema/SemaChecking.cpp
===
--- cfe/trunk/lib/Sema/SemaChecking.cpp
+++ cfe/trunk/lib/Sema/SemaChecking.cpp
@@ -8955,6 +8955,16 @@
   LHS = LHS->IgnoreParenImpCasts();
   RHS = RHS->IgnoreParenImpCasts();
 
+  if (!S.getLangOpts().CPlusPlus) {
+// Avoid warning about comparison of integers with different signs when
+// RHS/LHS has a `typeof(E)` type whose sign is different from the sign of
+// the type of `E`.
+if (const auto *TET = dyn_cast(LHS->getType()))
+  LHS = TET->getUnderlyingExpr()->IgnoreParenImpCasts();
+if (const auto *TET = dyn_cast(RHS->getType()))
+  RHS = TET->getUnderlyingExpr()->IgnoreParenImpCasts();
+  }
+
   // Check to see if one of the (unmodified) operands is of different
   // signedness.
   Expr *signedOperand, *unsignedOperand;
Index: cfe/trunk/test/Sema/compare.c
===
--- cfe/trunk/test/Sema/compare.c
+++ cfe/trunk/test/Sema/compare.c
@@ -391,3 +391,16 @@
 void test12(unsigned a) {
   if (0 && -1 > a) { }
 }
+
+// PR36008
+
+enum PR36008EnumTest {
+  kPR36008Value = 0,
+};
+
+void pr36008(enum PR36008EnumTest lhs) {
+  __typeof__(lhs) x = lhs;
+  __typeof__(kPR36008Value) y = (kPR36008Value);
+  if (x == y) x = y; // no warning
+  if (y == x) y = x; // no warning
+}


Index: cfe/trunk/lib/Sema/SemaChecking.cpp
===
--- cfe/trunk/lib/Sema/SemaChecking.cpp
+++ cfe/trunk/lib/Sema/SemaChecking.cpp
@@ -8955,6 +8955,16 @@
   LHS = LHS->IgnoreParenImpCasts();
   RHS = RHS->IgnoreParenImpCasts();
 
+  if (!S.getLangOpts().CPlusPlus) {
+// Avoid warning about comparison of integers with different signs when
+// RHS/LHS has a `typeof(E)` type whose sign is different from the sign of
+// the type of `E`.
+if (const auto *TET = dyn_cast(LHS->getType()))
+  LHS = TET->getUnderlyingExpr()->IgnoreParenImpCasts();
+if (const auto *TET = dyn_cast(RHS->getType()))
+  RHS = TET->getUnderlyingExpr()->IgnoreParenImpCasts();
+  }
+
   // Check to see if one of the (unmodified) operands is of different
   // signedness.
   Expr *signedOperand, *unsignedOperand;
Index: cfe/trunk/test/Sema/compare.c
===
--- cfe/trunk/test/Sema/compare.c
+++ cfe/trunk/test/Sema/compare.c
@@ -391,3 +391,16 @@
 void test12(unsigned a) {
   if (0 && -1 > a) { }
 }
+
+// PR36008
+
+enum PR36008EnumTest {
+  kPR36008Value = 0,
+};
+
+void pr36008(enum PR36008EnumTest lhs) {
+  __typeof__(lhs) x = lhs;
+  __typeof__(kPR36008Value) y = (kPR36008Value);
+  if (x == y) x = y; // no warning
+  if (y == x) y = x; // no warning
+}
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[libunwind] r324525 - Creating release candidate rc2 from release_600 branch

2018-02-07 Thread Hans Wennborg via cfe-commits
Author: hans
Date: Wed Feb  7 12:47:12 2018
New Revision: 324525

URL: http://llvm.org/viewvc/llvm-project?rev=324525=rev
Log:
Creating release candidate rc2 from release_600 branch

Added:
libunwind/tags/RELEASE_600/rc2/
  - copied from r324524, libunwind/branches/release_60/

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


[PATCH] D42993: [AArch64] Fixes for ARMv8.2-A FP16 scalar intrinsic

2018-02-07 Thread Sjoerd Meijer via Phabricator via cfe-commits
SjoerdMeijer added a comment.

Thanks for fixing this. Looks very reasonable to me.

Question about the failures: I am now wondering if this means we were and still 
are missing tests?

Nit: for future reviews, I think it is better to split patches up if they are 
commits to 
different repos.


https://reviews.llvm.org/D42993



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


[libcxxabi] r324519 - Creating release candidate rc2 from release_600 branch

2018-02-07 Thread Hans Wennborg via cfe-commits
Author: hans
Date: Wed Feb  7 12:46:26 2018
New Revision: 324519

URL: http://llvm.org/viewvc/llvm-project?rev=324519=rev
Log:
Creating release candidate rc2 from release_600 branch

Added:
libcxxabi/tags/RELEASE_600/rc2/
  - copied from r324518, libcxxabi/branches/release_60/

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


[libcxx] r324518 - Creating release candidate rc2 from release_600 branch

2018-02-07 Thread Hans Wennborg via cfe-commits
Author: hans
Date: Wed Feb  7 12:46:19 2018
New Revision: 324518

URL: http://llvm.org/viewvc/llvm-project?rev=324518=rev
Log:
Creating release candidate rc2 from release_600 branch

Added:
libcxx/tags/RELEASE_600/rc2/   (props changed)
  - copied from r324517, libcxx/branches/release_60/

Propchange: libcxx/tags/RELEASE_600/rc2/
--
--- svn:mergeinfo (added)
+++ svn:mergeinfo Wed Feb  7 12:46:19 2018
@@ -0,0 +1,2 @@
+/libcxx/branches/apple:136569-137939
+/libcxx/trunk:321963,324153


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


r324514 - [PR36008] Avoid -Wsign-compare warning for enum constants in

2018-02-07 Thread Alex Lorenz via cfe-commits
Author: arphaman
Date: Wed Feb  7 12:45:39 2018
New Revision: 324514

URL: http://llvm.org/viewvc/llvm-project?rev=324514=rev
Log:
[PR36008] Avoid -Wsign-compare warning for enum constants in
typeof expressions

This commit looks through typeof type at the original expression when diagnosing
-Wsign-compare to avoid an unfriendly diagnostic.

rdar://36588828

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

Modified:
cfe/trunk/lib/Sema/SemaChecking.cpp
cfe/trunk/test/Sema/compare.c

Modified: cfe/trunk/lib/Sema/SemaChecking.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaChecking.cpp?rev=324514=324513=324514=diff
==
--- cfe/trunk/lib/Sema/SemaChecking.cpp (original)
+++ cfe/trunk/lib/Sema/SemaChecking.cpp Wed Feb  7 12:45:39 2018
@@ -8955,6 +8955,16 @@ static void AnalyzeComparison(Sema , B
   LHS = LHS->IgnoreParenImpCasts();
   RHS = RHS->IgnoreParenImpCasts();
 
+  if (!S.getLangOpts().CPlusPlus) {
+// Avoid warning about comparison of integers with different signs when
+// RHS/LHS has a `typeof(E)` type whose sign is different from the sign of
+// the type of `E`.
+if (const auto *TET = dyn_cast(LHS->getType()))
+  LHS = TET->getUnderlyingExpr()->IgnoreParenImpCasts();
+if (const auto *TET = dyn_cast(RHS->getType()))
+  RHS = TET->getUnderlyingExpr()->IgnoreParenImpCasts();
+  }
+
   // Check to see if one of the (unmodified) operands is of different
   // signedness.
   Expr *signedOperand, *unsignedOperand;

Modified: cfe/trunk/test/Sema/compare.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/compare.c?rev=324514=324513=324514=diff
==
--- cfe/trunk/test/Sema/compare.c (original)
+++ cfe/trunk/test/Sema/compare.c Wed Feb  7 12:45:39 2018
@@ -391,3 +391,16 @@ typedef char two_chars[2];
 void test12(unsigned a) {
   if (0 && -1 > a) { }
 }
+
+// PR36008
+
+enum PR36008EnumTest {
+  kPR36008Value = 0,
+};
+
+void pr36008(enum PR36008EnumTest lhs) {
+  __typeof__(lhs) x = lhs;
+  __typeof__(kPR36008Value) y = (kPR36008Value);
+  if (x == y) x = y; // no warning
+  if (y == x) y = x; // no warning
+}


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


[PATCH] D43013: ASan+operator new[]: Fix operator new[] cookie poisoning

2018-02-07 Thread John McCall via Phabricator via cfe-commits
rjmccall added a comment.

I don't understand why your description of this patch mentions the void* 
placement new[] operator.  There's no cookie to poison for that operator.


Repository:
  rC Clang

https://reviews.llvm.org/D43013



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


r324507 - [analyzer] [NFC] Factor out generating path diagnostics for a statement into a function

2018-02-07 Thread George Karpenkov via cfe-commits
Author: george.karpenkov
Date: Wed Feb  7 11:56:52 2018
New Revision: 324507

URL: http://llvm.org/viewvc/llvm-project?rev=324507=rev
Log:
[analyzer] [NFC] Factor out generating path diagnostics for a statement into a 
function

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

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

Modified: cfe/trunk/lib/StaticAnalyzer/Core/BugReporter.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Core/BugReporter.cpp?rev=324507=324506=324507=diff
==
--- cfe/trunk/lib/StaticAnalyzer/Core/BugReporter.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Core/BugReporter.cpp Wed Feb  7 11:56:52 2018
@@ -556,330 +556,330 @@ static void updateStackPiecesWithMessage
 
 static void CompactPathDiagnostic(PathPieces , const SourceManager& SM);
 
-static bool GenerateMinimalPathDiagnostic(
-PathDiagnostic , PathDiagnosticBuilder , const ExplodedNode *N,
-LocationContextMap ,
-ArrayRef visitors) {
 
+/// Add path diagnostic for statement associated with node \p N
+/// to diagnostics \p PD.
+/// Precondition: location associated with \p N is a \c BlockEdge.
+static void generateMinimalDiagnosticsForBlockEdge(const ExplodedNode *N,
+   PathDiagnosticBuilder ,
+   PathDiagnostic ) {
+
+  const LocationContext *LC = N->getLocationContext();
   SourceManager& SMgr = PDB.getSourceManager();
-  const LocationContext *LC = PDB.LC;
-  const ExplodedNode *NextNode = N->pred_empty()
-? nullptr : *(N->pred_begin());
+  BlockEdge BE = N->getLocation().castAs();
+  const CFGBlock *Src = BE.getSrc();
+  const CFGBlock *Dst = BE.getDst();
+  const Stmt *T = Src->getTerminator();
+  if (!T)
+return;
 
-  StackDiagVector CallStack;
+  auto Start = PathDiagnosticLocation::createBegin(T, SMgr, LC);
+  switch (T->getStmtClass()) {
+  default:
+break;
+
+  case Stmt::GotoStmtClass:
+  case Stmt::IndirectGotoStmtClass: {
+const Stmt *S = PathDiagnosticLocation::getNextStmt(N);
 
-  while (NextNode) {
-N = NextNode;
-PDB.LC = N->getLocationContext();
-NextNode = N->getFirstPred();
+if (!S)
+  break;
 
-ProgramPoint P = N->getLocation();
+std::string sbuf;
+llvm::raw_string_ostream os(sbuf);
+const PathDiagnosticLocation  = PDB.getEnclosingStmtLocation(S);
+
+os << "Control jumps to line " << 
End.asLocation().getExpansionLineNumber();
+PD.getActivePath().push_front(
+std::make_shared(Start, End, 
os.str()));
+break;
+  }
+
+  case Stmt::SwitchStmtClass: {
+// Figure out what case arm we took.
+std::string sbuf;
+llvm::raw_string_ostream os(sbuf);
 
-do {
-  if (Optional CE = P.getAs()) {
-auto C = PathDiagnosticCallPiece::construct(N, *CE, SMgr);
-// Record the mapping from call piece to LocationContext.
-LCM[>path] = CE->getCalleeContext();
-auto *P = C.get();
-PD.getActivePath().push_front(std::move(C));
-PD.pushActivePath(>path);
-CallStack.push_back(StackDiagPair(P, N));
+if (const Stmt *S = Dst->getLabel()) {
+  PathDiagnosticLocation End(S, SMgr, LC);
+
+  switch (S->getStmtClass()) {
+  default:
+os << "No cases match in the switch statement. "
+  "Control jumps to line "
+   << End.asLocation().getExpansionLineNumber();
+break;
+  case Stmt::DefaultStmtClass:
+os << "Control jumps to the 'default' case at line "
+   << End.asLocation().getExpansionLineNumber();
 break;
-  }
 
-  if (Optional CE = P.getAs()) {
-// Flush all locations, and pop the active path.
-bool VisitedEntireCall = PD.isWithinCall();
-PD.popActivePath();
-
-// Either we just added a bunch of stuff to the top-level path, or
-// we have a previous CallExitEnd.  If the former, it means that the
-// path terminated within a function call.  We must then take the
-// current contents of the active path and place it within
-// a new PathDiagnosticCallPiece.
-PathDiagnosticCallPiece *C;
-if (VisitedEntireCall) {
-  C = cast(PD.getActivePath().front().get());
-} else {
-  const Decl *Caller = CE->getLocationContext()->getDecl();
-  C = PathDiagnosticCallPiece::construct(PD.getActivePath(), Caller);
-  // Record the mapping from call piece to LocationContext.
-  LCM[>path] = CE->getCalleeContext();
+  case Stmt::CaseStmtClass: {
+os << "Control jumps to 'case ";
+const CaseStmt *Case = cast(S);
+const Expr *LHS = Case->getLHS()->IgnoreParenCasts();
+
+// Determine if it is an enum.
+bool GetRawInt = true;
+
+if (const DeclRefExpr *DR = dyn_cast(LHS)) {
+  // FIXME: Maybe 

r324508 - Revert [DebugInfo] Improvements to representation of enumeration types (PR36168)"

2018-02-07 Thread Momchil Velikov via cfe-commits
Author: chill
Date: Wed Feb  7 11:57:04 2018
New Revision: 324508

URL: http://llvm.org/viewvc/llvm-project?rev=324508=rev
Log:
Revert [DebugInfo] Improvements to representation of enumeration types 
(PR36168)"

Revert due to breaking buildbots (LLDB tests)

Removed:
cfe/trunk/test/CodeGen/debug-info-enum.cpp
Modified:
cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
cfe/trunk/test/CodeGenCXX/debug-info-enum-class.cpp
cfe/trunk/test/CodeGenCXX/debug-info-enum.cpp
cfe/trunk/test/Modules/ModuleDebugInfo.cpp

Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.cpp?rev=324508=324507=324508=diff
==
--- cfe/trunk/lib/CodeGen/CGDebugInfo.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGDebugInfo.cpp Wed Feb  7 11:57:04 2018
@@ -2492,12 +2492,9 @@ llvm::DIType *CGDebugInfo::CreateTypeDef
   // Create elements for each enumerator.
   SmallVector Enumerators;
   ED = ED->getDefinition();
-  bool IsSigned = ED->getIntegerType()->isSignedIntegerType();
   for (const auto *Enum : ED->enumerators()) {
-const auto  = Enum->getInitVal();
-auto Value = IsSigned ? InitVal.getSExtValue() : InitVal.getZExtValue();
-Enumerators.push_back(
-DBuilder.createEnumerator(Enum->getName(), Value, !IsSigned));
+Enumerators.push_back(DBuilder.createEnumerator(
+Enum->getName(), Enum->getInitVal().getSExtValue()));
   }
 
   // Return a CompositeType for the enum itself.
@@ -2506,10 +2503,11 @@ llvm::DIType *CGDebugInfo::CreateTypeDef
   llvm::DIFile *DefUnit = getOrCreateFile(ED->getLocation());
   unsigned Line = getLineNumber(ED->getLocation());
   llvm::DIScope *EnumContext = getDeclContextDescriptor(ED);
-  llvm::DIType *ClassTy = getOrCreateType(ED->getIntegerType(), DefUnit);
+  llvm::DIType *ClassTy =
+  ED->isFixed() ? getOrCreateType(ED->getIntegerType(), DefUnit) : nullptr;
   return DBuilder.createEnumerationType(EnumContext, ED->getName(), DefUnit,
 Line, Size, Align, EltArray, ClassTy,
-FullName, ED->isFixed());
+FullName);
 }
 
 llvm::DIMacro *CGDebugInfo::CreateMacro(llvm::DIMacroFile *Parent,

Removed: cfe/trunk/test/CodeGen/debug-info-enum.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/debug-info-enum.cpp?rev=324507=auto
==
--- cfe/trunk/test/CodeGen/debug-info-enum.cpp (original)
+++ cfe/trunk/test/CodeGen/debug-info-enum.cpp (removed)
@@ -1,100 +0,0 @@
-// Test enumeration representation in debuig info metadata:
-// * test value representation for each possible underlying integer type
-// * test the integer type is as expected
-// * test the DW_AT_enum_class attribute is present (resp. absent) as expected.
-
-// RUN: %clang -target x86_64-linux -g -S -emit-llvm -o - %s | FileCheck %s
-
-
-enum class E0 : signed char {
-  A0 = -128,
-  B0 = 127,
-} x0;
-// CHECK: !DICompositeType(tag: DW_TAG_enumeration_type, name: "E0"
-// CHECK-SAME: baseType: ![[SCHAR:[0-9]+]]
-// CHECK-SAME: DIFlagFixedEnum
-// CHECK-SAME: elements: ![[ELTS0:[0-9]+]]
-// CHECK: ![[SCHAR]] = !DIBasicType(name: "signed char", size: 8, encoding: 
DW_ATE_signed_char)
-// CHECK: ![[ELTS0]] = !{![[A0:[0-9]+]], ![[B0:[0-9]+]]}
-// CHECK: ![[A0]] = !DIEnumerator(name: "A0", value: -128)
-// CHECK: ![[B0]] = !DIEnumerator(name: "B0", value: 127)
-
-enum class E1 : unsigned char { A1 = 255 } x1;
-// CHECK: !DICompositeType(tag: DW_TAG_enumeration_type, name: "E1"
-// CHECK-SAME: baseType: ![[UCHAR:[0-9]+]]
-// CHECK-SAME: DIFlagFixedEnum
-// CHECK-SAME: elements: ![[ELTS1:[0-9]+]]
-// CHECK: ![[UCHAR]] = !DIBasicType(name: "unsigned char", size: 8, encoding: 
DW_ATE_unsigned_char)
-// CHECK: ![[ELTS1]] = !{![[A1:[0-9]+]]}
-// CHECK: ![[A1]] = !DIEnumerator(name: "A1", value: 255, isUnsigned: true)
-
-enum class E2 : signed short {
-  A2 = -32768,
-  B2 = 32767,
-} x2;
-// CHECK: !DICompositeType(tag: DW_TAG_enumeration_type, name: "E2"
-// CHECK-SAME: baseType: ![[SHORT:[0-9]+]]
-// CHECK-SAME: DIFlagFixedEnum
-// CHECK-SAME: elements: ![[ELTS2:[0-9]+]]
-// CHECK: ![[SHORT]] = !DIBasicType(name: "short", size: 16, encoding: 
DW_ATE_signed)
-// CHECK: ![[ELTS2]] = !{![[A2:[0-9]+]], ![[B2:[0-9]+]]}
-// CHECK: ![[A2]] = !DIEnumerator(name: "A2", value: -32768)
-// CHECK: ![[B2]] = !DIEnumerator(name: "B2", value: 32767)
-
-enum class E3 : unsigned short { A3 = 65535 } x3;
-// CHECK: !DICompositeType(tag: DW_TAG_enumeration_type, name: "E3"
-// CHECK-SAME: baseType: ![[USHORT:[0-9]+]]
-// CHECK-SAME: DIFlagFixedEnum
-// CHECK-SAME: elements: ![[ELTS3:[0-9]+]]
-// CHECK: ![[USHORT]] = !DIBasicType(name: "unsigned short", size: 16, 
encoding: DW_ATE_unsigned)
-// CHECK: ![[ELTS3]] = !{![[A3:[0-9]+]]}
-// CHECK: ![[A3]] = !DIEnumerator(name: "A3", value: 65535, 

r324505 - Revert "Recommit r324107."

2018-02-07 Thread Rafael Espindola via cfe-commits
Author: rafael
Date: Wed Feb  7 11:44:15 2018
New Revision: 324505

URL: http://llvm.org/viewvc/llvm-project?rev=324505=rev
Log:
Revert "Recommit r324107."

This reverts commit r324500.

The bots found two failures:

ThreadSanitizer-x86_64 :: Linux/pie_no_aslr.cc
ThreadSanitizer-x86_64 :: pie_test.cc

when using gold. The issue is a limitation in gold when building pie
binaries. I will investigate how to work around it.

Removed:
cfe/trunk/test/CodeGen/dso-local-executable.c
cfe/trunk/test/CodeGenCXX/dso-local-executable.cpp
Modified:
cfe/trunk/lib/CodeGen/CGDecl.cpp
cfe/trunk/lib/CodeGen/CGVTT.cpp
cfe/trunk/lib/CodeGen/CGVTables.cpp
cfe/trunk/lib/CodeGen/CodeGenModule.cpp
cfe/trunk/lib/CodeGen/CodeGenModule.h
cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp
cfe/trunk/test/CodeGen/mbackchain-2.c
cfe/trunk/test/CodeGen/mbackchain-3.c
cfe/trunk/test/CodeGen/mips-vector-return.c
cfe/trunk/test/CodeGen/split-stacks.c
cfe/trunk/test/CodeGenCXX/debug-info-static-member.cpp
cfe/trunk/test/CodeGenCXX/debug-info-template.cpp
cfe/trunk/test/CodeGenCXX/float16-declarations.cpp
cfe/trunk/test/CodeGenCXX/split-stacks.cpp
cfe/trunk/test/Driver/lanai-unknown-unknown.cpp
cfe/trunk/test/Driver/le32-unknown-nacl.cpp
cfe/trunk/test/Driver/le64-unknown-unknown.cpp
cfe/trunk/test/Driver/riscv32-toolchain.c
cfe/trunk/test/Driver/riscv64-toolchain.c
cfe/trunk/test/Frontend/ast-codegen.c

Modified: cfe/trunk/lib/CodeGen/CGDecl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDecl.cpp?rev=324505=324504=324505=diff
==
--- cfe/trunk/lib/CodeGen/CGDecl.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGDecl.cpp Wed Feb  7 11:44:15 2018
@@ -240,7 +240,7 @@ llvm::Constant *CodeGenModule::getOrCrea
   getModule(), LTy, Ty.isConstant(getContext()), Linkage, Init, Name,
   nullptr, llvm::GlobalVariable::NotThreadLocal, TargetAS);
   GV->setAlignment(getContext().getDeclAlign().getQuantity());
-  setGVProperties(GV, );
+  setGlobalVisibility(GV, );
 
   if (supportsCOMDAT() && GV->isWeakForLinker())
 GV->setComdat(TheModule.getOrInsertComdat(GV->getName()));
@@ -344,7 +344,6 @@ CodeGenFunction::AddInitializerToStaticV
   OldGV->getThreadLocalMode(),

CGM.getContext().getTargetAddressSpace(D.getType()));
 GV->setVisibility(OldGV->getVisibility());
-GV->setDSOLocal(OldGV->isDSOLocal());
 GV->setComdat(OldGV->getComdat());
 
 // Steal the name of the old global

Modified: cfe/trunk/lib/CodeGen/CGVTT.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGVTT.cpp?rev=324505=324504=324505=diff
==
--- cfe/trunk/lib/CodeGen/CGVTT.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGVTT.cpp Wed Feb  7 11:44:15 2018
@@ -100,7 +100,7 @@ CodeGenVTables::EmitVTTDefinition(llvm::
 VTT->setComdat(CGM.getModule().getOrInsertComdat(VTT->getName()));
 
   // Set the right visibility.
-  CGM.setGVProperties(VTT, RD);
+  CGM.setGlobalVisibility(VTT, RD);
 }
 
 llvm::GlobalVariable *CodeGenVTables::GetAddrOfVTT(const CXXRecordDecl *RD) {

Modified: cfe/trunk/lib/CodeGen/CGVTables.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGVTables.cpp?rev=324505=324504=324505=diff
==
--- cfe/trunk/lib/CodeGen/CGVTables.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGVTables.cpp Wed Feb  7 11:44:15 2018
@@ -51,7 +51,7 @@ llvm::Constant *CodeGenModule::GetAddrOf
 
 static void setThunkVisibility(CodeGenModule , const CXXMethodDecl *MD,
const ThunkInfo , llvm::Function *Fn) {
-  CGM.setGVProperties(Fn, MD);
+  CGM.setGlobalVisibility(Fn, MD);
 }
 
 static void setThunkProperties(CodeGenModule , const ThunkInfo ,
@@ -730,7 +730,7 @@ CodeGenVTables::GenerateConstructionVTab
   // Create the variable that will hold the construction vtable.
   llvm::GlobalVariable *VTable =
 CGM.CreateOrReplaceCXXRuntimeVariable(Name, VTType, Linkage);
-  CGM.setGVProperties(VTable, RD);
+  CGM.setGlobalVisibility(VTable, RD);
 
   // V-tables are always unnamed_addr.
   VTable->setUnnamedAddr(llvm::GlobalValue::UnnamedAddr::Global);

Modified: cfe/trunk/lib/CodeGen/CodeGenModule.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenModule.cpp?rev=324505=324504=324505=diff
==
--- cfe/trunk/lib/CodeGen/CodeGenModule.cpp (original)
+++ cfe/trunk/lib/CodeGen/CodeGenModule.cpp Wed Feb  7 11:44:15 2018
@@ -715,62 +715,6 @@ void CodeGenModule::setGlobalVisibility(
 GV->setVisibility(GetLLVMVisibility(LV.getVisibility()));
 }
 
-static bool shouldAssumeDSOLocal(const CodeGenModule ,
- llvm::GlobalValue 

[PATCH] D43035: Use 'wasm' over 'wasm32' as default arch name

2018-02-07 Thread Sam Clegg via Phabricator via cfe-commits
sbc100 created this revision.
Herald added subscribers: cfe-commits, sunfish, aheejin, jgravelle-google, 
dschuff, jfb.

Repository:
  rC Clang

https://reviews.llvm.org/D43035

Files:
  include/clang/Basic/TargetCXXABI.h
  lib/Basic/Targets.cpp
  lib/Basic/Targets/WebAssembly.cpp
  lib/CodeGen/CGBuiltin.cpp
  lib/CodeGen/TargetInfo.cpp
  lib/Driver/Driver.cpp
  lib/Driver/ToolChain.cpp
  lib/Driver/ToolChains/Clang.cpp
  lib/Driver/ToolChains/CommonArgs.cpp
  test/Preprocessor/init.c

Index: test/Preprocessor/init.c
===
--- test/Preprocessor/init.c
+++ test/Preprocessor/init.c
@@ -9382,11 +9382,9 @@
 // WEBASSEMBLY32-NOT:#define __unix
 // WEBASSEMBLY32-NOT:#define __unix__
 // WEBASSEMBLY32-NEXT:#define __wasm 1
-// WEBASSEMBLY32-NEXT:#define __wasm32 1
-// WEBASSEMBLY32-NEXT:#define __wasm32__ 1
+// WEBASSEMBLY32-NEXT:#define __wasm__ 1
 // WEBASSEMBLY32-NOT:#define __wasm64
 // WEBASSEMBLY32-NOT:#define __wasm64__
-// WEBASSEMBLY32-NEXT:#define __wasm__ 1
 //
 // RUN: %clang_cc1 -E -dM -ffreestanding -triple=wasm64-unknown-unknown \
 // RUN:   < /dev/null \
Index: lib/Driver/ToolChains/CommonArgs.cpp
===
--- lib/Driver/ToolChains/CommonArgs.cpp
+++ lib/Driver/ToolChains/CommonArgs.cpp
@@ -347,7 +347,7 @@
   case llvm::Triple::amdgcn:
 return getR600TargetGPU(Args);
 
-  case llvm::Triple::wasm32:
+  case llvm::Triple::wasm:
   case llvm::Triple::wasm64:
 return getWebAssemblyTargetCPU(Args);
   }
Index: lib/Driver/ToolChains/Clang.cpp
===
--- lib/Driver/ToolChains/Clang.cpp
+++ lib/Driver/ToolChains/Clang.cpp
@@ -346,7 +346,7 @@
   case llvm::Triple::hexagon:
 hexagon::getHexagonTargetFeatures(D, Args, Features);
 break;
-  case llvm::Triple::wasm32:
+  case llvm::Triple::wasm:
   case llvm::Triple::wasm64:
 getWebAssemblyTargetFeatures(Args, Features);
 break;
@@ -524,7 +524,7 @@
   const llvm::Triple ) {
   switch (Triple.getArch()) {
   case llvm::Triple::xcore:
-  case llvm::Triple::wasm32:
+  case llvm::Triple::wasm:
   case llvm::Triple::wasm64:
 // XCore never wants frame pointers, regardless of OS.
 // WebAssembly never wants frame pointers.
@@ -1309,7 +1309,7 @@
 return false;
 
   case llvm::Triple::xcore:
-  case llvm::Triple::wasm32:
+  case llvm::Triple::wasm:
   case llvm::Triple::wasm64:
 return true;
   }
@@ -1434,7 +1434,7 @@
 AddHexagonTargetArgs(Args, CmdArgs);
 break;
 
-  case llvm::Triple::wasm32:
+  case llvm::Triple::wasm:
   case llvm::Triple::wasm64:
 AddWebAssemblyTargetArgs(Args, CmdArgs);
 break;
Index: lib/Driver/ToolChain.cpp
===
--- lib/Driver/ToolChain.cpp
+++ lib/Driver/ToolChain.cpp
@@ -480,7 +480,7 @@
Triple.getArch() == llvm::Triple::armeb ||
Triple.getArch() == llvm::Triple::thumb ||
Triple.getArch() == llvm::Triple::thumbeb ||
-   Triple.getArch() == llvm::Triple::wasm32 ||
+   Triple.getArch() == llvm::Triple::wasm ||
Triple.getArch() == llvm::Triple::wasm64;
   } else if (Model == "posix")
 return true;
@@ -793,7 +793,7 @@
   getTriple().getArch() == llvm::Triple::x86_64 ||
   getTriple().getArch() == llvm::Triple::arm ||
   getTriple().getArch() == llvm::Triple::aarch64 ||
-  getTriple().getArch() == llvm::Triple::wasm32 ||
+  getTriple().getArch() == llvm::Triple::wasm ||
   getTriple().getArch() == llvm::Triple::wasm64)
 Res |= CFIICall;
   return Res;
Index: lib/Driver/Driver.cpp
===
--- lib/Driver/Driver.cpp
+++ lib/Driver/Driver.cpp
@@ -4193,7 +4193,7 @@
   case llvm::Triple::xcore:
 TC = llvm::make_unique(*this, Target, Args);
 break;
-  case llvm::Triple::wasm32:
+  case llvm::Triple::wasm:
   case llvm::Triple::wasm64:
 TC = llvm::make_unique(*this, Target, Args);
 break;
Index: lib/CodeGen/TargetInfo.cpp
===
--- lib/CodeGen/TargetInfo.cpp
+++ lib/CodeGen/TargetInfo.cpp
@@ -9000,7 +9000,7 @@
 return SetCGInfo(new AArch64TargetCodeGenInfo(Types, Kind));
   }
 
-  case llvm::Triple::wasm32:
+  case llvm::Triple::wasm:
   case llvm::Triple::wasm64:
 return SetCGInfo(new WebAssemblyTargetCodeGenInfo(Types));
 
Index: lib/CodeGen/CGBuiltin.cpp
===
--- lib/CodeGen/CGBuiltin.cpp
+++ lib/CodeGen/CGBuiltin.cpp
@@ -3416,7 +3416,7 @@
   case llvm::Triple::nvptx:
   case llvm::Triple::nvptx64:
 return CGF->EmitNVPTXBuiltinExpr(BuiltinID, E);
-  case llvm::Triple::wasm32:
+  case llvm::Triple::wasm:
   case llvm::Triple::wasm64:
 return 

[libcxx] r324503 - Comment on 'Review' issues

2018-02-07 Thread Marshall Clow via cfe-commits
Author: marshall
Date: Wed Feb  7 11:24:37 2018
New Revision: 324503

URL: http://llvm.org/viewvc/llvm-project?rev=324503=rev
Log:
Comment on 'Review' issues

Modified:
libcxx/trunk/www/upcoming_meeting.html

Modified: libcxx/trunk/www/upcoming_meeting.html
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/www/upcoming_meeting.html?rev=324503=324502=324503=diff
==
--- libcxx/trunk/www/upcoming_meeting.html (original)
+++ libcxx/trunk/www/upcoming_meeting.html Wed Feb  7 11:24:37 2018
@@ -32,7 +32,7 @@
 
 
   
-  libc++ Upcoming Metting Status
+  libc++ Upcoming Meeting Status
   
 
   This is a temporary page; please check the c++1z status here
@@ -97,7 +97,7 @@
 Issues to "Review"
 
 Issue #Issue NameMeetingStatus
-https://wg21.link/LWG2412;>2412promise::set_value() 
and promise::get_future() should not 
raceJacksonville
+https://wg21.link/LWG2412;>2412promise::set_value() 
and promise::get_future() should not 
raceJacksonvilleComplete
 https://wg21.link/LWG2682;>2682filesystem::copy()
 won't create a symlink to a directoryJacksonville
 https://wg21.link/LWG2697;>2697[concurr.ts] 
Behavior of future/shared_future unwrapping constructor when given an 
invalid futureJacksonville
 https://wg21.link/LWG2708;>2708recursive_directory_iterator::recursion_pending()
 is incorrectly specifiedJacksonville
@@ -143,14 +143,14 @@
 
 Comments about the "Review" issues
 
- 2412 - 
- 2682 - 
- 2697 - 
- 2708 - 
- 2936 - 
+ 2412 - I think we do this already
+ 2682 - Eric - don't we do this already? 
+ 2697 - No concurrency TS implementation yet
+ 2708 - Eric? 
+ 2936 - Eric - don't we do this already?
 
 
-Last Updated: 5-Feb-2018
+Last Updated: 7-Feb-2018
 
 
 


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


[PATCH] D42983: [clang-tidy] Add readability-simd-intrinsics check.

2018-02-07 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri added inline comments.



Comment at: clang-tidy/readability/SIMDIntrinsicsCheck.cpp:75
+  // libcxx implementation of std::experimental::simd requires at least C++11.
+  if (!Result.Context->getLangOpts().CPlusPlus11)
+return;

timshen wrote:
> MaskRay wrote:
> > lebedev.ri wrote:
> > > Is it reasonable to suggest to use ``?
> > > I would guess it should be `CPlusPlus2a`
> > Added a check-specific option `readability-simd-intrinsics.Experiment`.
> > 
> > 
> > Is it reasonable to suggest to use ?
> 
> I think there are two approaches to proceed:
> 1) We just warn the users, but don't suggest  fixes.
> 2) We warn and suggest  fixes, but only when a flag is 
> turned on (off by default). The flag documentation should clearly include 
> "suggest  API".
> 
> I'm not sure which one fits better.
Ok, i should have commented in more words :)

I wasn't questioning the use of ``
I was questioning the whole approach of **defaulting** to issuing the warning 
as long as that header can be used with **specified** C++ standard.
E.g. there is ``, but there isn't any check to 
complain on `fopen()`/`fclose()` and friends.
(I do agree that this argument is chicken-or-the-egg problem)



Comment at: clang-tidy/readability/SIMDIntrinsicsCheck.cpp:87
+return;
+  bool IsVector = Callee->getReturnType()->isVectorType();
+  for (const ParmVarDecl *Parm : Callee->parameters()) {

MaskRay wrote:
> lebedev.ri wrote:
> > Same here, i *think* something like this would be better?
> > ```
> > AST_MATCHER(FunctionDecl, isVectorFunction) {
> >  bool IsVector = Node.getReturnType()->isVectorType();
> >   for (const ParmVarDecl *Parm : Node.parameters()) {
> > QualType Type = Parm->getType();
> > if (Type->isPointerType())
> >   Type = Type->getPointeeType();
> > if (Type->isVectorType())
> >   IsVector = true;
> > 
> >   return IsVector;
> > }
> > ```
> > +
> > ```
> > void SIMDIntrinsicsCheck::registerMatchers(MatchFinder *Finder) {
> >   Finder->addMatcher(
> >   callExpr(callee(
> > allOf(
> >  functionDecl(
> > +   allOf(
> >  matchesName("^::(_mm_|_mm256_|_mm512_|vec_)")
> > + , isVectorFunction()
> > +   )
> >   , hasDirectCallee()
> > )
> >)),
> >unless(isExpansionInSystemHeader()))
> >   .bind("call"),
> >   this);
> > }
> > ```
> Thanks! Added isVectorFunction. I guess I may should use unnamed namespace 
> for AST_MATCHER, but do I also need the unnamed namespace to enclose 
> TrySuggestPPC and TrySuggestX86?
> I may should use unnamed namespace for AST_MATCHER

I //think// so.

> do I also need the unnamed namespace to enclose TrySuggestPPC and 
> TrySuggestX86?

No, but do make those `static`.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D42983



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


[PATCH] D43033: [WinEH] Put funclet bundles on inline asm calls

2018-02-07 Thread Reid Kleckner via Phabricator via cfe-commits
rnk created this revision.
rnk added reviewers: smeenai, majnemer.
Herald added a subscriber: eraman.

Fixes PR36247, which is where WinEHPrepare replaces inline asm in
funclets with unreachable.

Make getBundlesForFunclet return by value to simplify some call sites.


https://reviews.llvm.org/D43033

Files:
  clang/lib/CodeGen/CGCall.cpp
  clang/lib/CodeGen/CGStmt.cpp
  clang/lib/CodeGen/CodeGenFunction.h
  clang/test/CodeGenCXX/microsoft-abi-eh-inlineasm.cpp

Index: clang/test/CodeGenCXX/microsoft-abi-eh-inlineasm.cpp
===
--- /dev/null
+++ clang/test/CodeGenCXX/microsoft-abi-eh-inlineasm.cpp
@@ -0,0 +1,18 @@
+// RUN: %clang_cc1 -std=c++11 -emit-llvm %s -o - -triple=x86_64-pc-windows-msvc \
+// RUN: -fexceptions -fcxx-exceptions | FileCheck %s
+
+// Make sure calls to inline asm have funclet bundles.
+
+extern "C" void might_throw();
+extern "C" void foo() {
+  try {
+might_throw();
+  } catch (int) {
+__asm__("nop");
+  }
+}
+
+// CHECK-LABEL: define void @foo()
+// CHECK: invoke void @might_throw()
+// CHECK: %[[CATCHPAD:[^ ]*]] = catchpad within
+// CHECK: call void asm sideeffect "nop", {{.*}} [ "funclet"(token %[[CATCHPAD]]) ]
Index: clang/lib/CodeGen/CodeGenFunction.h
===
--- clang/lib/CodeGen/CodeGenFunction.h
+++ clang/lib/CodeGen/CodeGenFunction.h
@@ -3367,6 +3367,9 @@
   ArrayRef args,
   const Twine  = "");
 
+  SmallVector
+  getBundlesForFunclet(llvm::Value *Callee);
+
   llvm::CallSite EmitCallOrInvoke(llvm::Value *Callee,
   ArrayRef Args,
   const Twine  = "");
Index: clang/lib/CodeGen/CGStmt.cpp
===
--- clang/lib/CodeGen/CGStmt.cpp
+++ clang/lib/CodeGen/CGStmt.cpp
@@ -2133,7 +2133,8 @@
   llvm::InlineAsm *IA =
 llvm::InlineAsm::get(FTy, AsmString, Constraints, HasSideEffect,
  /* IsAlignStack */ false, AsmDialect);
-  llvm::CallInst *Result = Builder.CreateCall(IA, Args);
+  llvm::CallInst *Result =
+  Builder.CreateCall(IA, Args, getBundlesForFunclet(IA));
   Result->addAttribute(llvm::AttributeList::FunctionIndex,
llvm::Attribute::NoUnwind);
 
Index: clang/lib/CodeGen/CGCall.cpp
===
--- clang/lib/CodeGen/CGCall.cpp
+++ clang/lib/CodeGen/CGCall.cpp
@@ -3608,40 +3608,39 @@
 
 // Calls which may throw must have operand bundles indicating which funclet
 // they are nested within.
-static void
-getBundlesForFunclet(llvm::Value *Callee, llvm::Instruction *CurrentFuncletPad,
- SmallVectorImpl ) {
+SmallVector
+CodeGenFunction::getBundlesForFunclet(llvm::Value *Callee) {
+  SmallVector BundleList;
   // There is no need for a funclet operand bundle if we aren't inside a
   // funclet.
   if (!CurrentFuncletPad)
-return;
+return BundleList;
 
   // Skip intrinsics which cannot throw.
   auto *CalleeFn = dyn_cast(Callee->stripPointerCasts());
   if (CalleeFn && CalleeFn->isIntrinsic() && CalleeFn->doesNotThrow())
-return;
+return BundleList;
 
   BundleList.emplace_back("funclet", CurrentFuncletPad);
+  return BundleList;
 }
 
 /// Emits a simple call (never an invoke) to the given runtime function.
 llvm::CallInst *
 CodeGenFunction::EmitRuntimeCall(llvm::Value *callee,
  ArrayRef args,
  const llvm::Twine ) {
-  SmallVector BundleList;
-  getBundlesForFunclet(callee, CurrentFuncletPad, BundleList);
-
-  llvm::CallInst *call = Builder.CreateCall(callee, args, BundleList, name);
+  llvm::CallInst *call =
+  Builder.CreateCall(callee, args, getBundlesForFunclet(callee), name);
   call->setCallingConv(getRuntimeCC());
   return call;
 }
 
 /// Emits a call or invoke to the given noreturn runtime function.
 void CodeGenFunction::EmitNoreturnRuntimeCallOrInvoke(llvm::Value *callee,
ArrayRef args) {
-  SmallVector BundleList;
-  getBundlesForFunclet(callee, CurrentFuncletPad, BundleList);
+  SmallVector BundleList =
+  getBundlesForFunclet(callee);
 
   if (getInvokeDest()) {
 llvm::InvokeInst *invoke = 
@@ -3684,8 +3683,8 @@
   ArrayRef Args,
   const Twine ) {
   llvm::BasicBlock *InvokeDest = getInvokeDest();
-  SmallVector BundleList;
-  getBundlesForFunclet(Callee, CurrentFuncletPad, BundleList);
+  SmallVector BundleList =
+  getBundlesForFunclet(Callee);
 
  

r324501 - Fix r324498: the commit removed the '-' before the disable-llvm-verifier flag

2018-02-07 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Wed Feb  7 11:17:03 2018
New Revision: 324501

URL: http://llvm.org/viewvc/llvm-project?rev=324501=rev
Log:
Fix r324498: the commit removed the '-' before the disable-llvm-verifier flag

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

Modified: cfe/trunk/lib/Driver/ToolChains/Clang.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Clang.cpp?rev=324501=324500=324501=diff
==
--- cfe/trunk/lib/Driver/ToolChains/Clang.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/Clang.cpp Wed Feb  7 11:17:03 2018
@@ -3274,7 +3274,7 @@ void Clang::ConstructJob(Compilation ,
 
   // Disable the verification pass in -asserts builds.
   if (!IsAssertBuild)
-CmdArgs.push_back("disable-llvm-verifier");
+CmdArgs.push_back("-disable-llvm-verifier");
 
   // Discard value names in assert builds unless otherwise specified.
   if (const Arg *A = Args.getLastArg(options::OPT_fdiscard_value_names,


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


r324500 - Recommit r324107.

2018-02-07 Thread Rafael Espindola via cfe-commits
Author: rafael
Date: Wed Feb  7 11:16:49 2018
New Revision: 324500

URL: http://llvm.org/viewvc/llvm-project?rev=324500=rev
Log:
Recommit r324107.

It now includes a fix to not mark available_externally definitions as
dso_local.

Original message:

Start setting dso_local in clang.

This starts adding dso_local to clang.

The hope is to eventually have TargetMachine::shouldAssumeDsoLocal go
away. My objective for now is to move enough of it to clang to remove
the need for the TargetMachine one to handle PIE copy relocations and
-fno-plt. With that it should then be easy to implement a
-fno-copy-reloc in clang.

This patch just adds the cases where we assume a symbol to be local
based on the file being compiled for an executable or a shared
library.

Added:
cfe/trunk/test/CodeGen/dso-local-executable.c
cfe/trunk/test/CodeGenCXX/dso-local-executable.cpp
Modified:
cfe/trunk/lib/CodeGen/CGDecl.cpp
cfe/trunk/lib/CodeGen/CGVTT.cpp
cfe/trunk/lib/CodeGen/CGVTables.cpp
cfe/trunk/lib/CodeGen/CodeGenModule.cpp
cfe/trunk/lib/CodeGen/CodeGenModule.h
cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp
cfe/trunk/test/CodeGen/mbackchain-2.c
cfe/trunk/test/CodeGen/mbackchain-3.c
cfe/trunk/test/CodeGen/mips-vector-return.c
cfe/trunk/test/CodeGen/split-stacks.c
cfe/trunk/test/CodeGenCXX/debug-info-static-member.cpp
cfe/trunk/test/CodeGenCXX/debug-info-template.cpp
cfe/trunk/test/CodeGenCXX/float16-declarations.cpp
cfe/trunk/test/CodeGenCXX/split-stacks.cpp
cfe/trunk/test/Driver/lanai-unknown-unknown.cpp
cfe/trunk/test/Driver/le32-unknown-nacl.cpp
cfe/trunk/test/Driver/le64-unknown-unknown.cpp
cfe/trunk/test/Driver/riscv32-toolchain.c
cfe/trunk/test/Driver/riscv64-toolchain.c
cfe/trunk/test/Frontend/ast-codegen.c

Modified: cfe/trunk/lib/CodeGen/CGDecl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDecl.cpp?rev=324500=324499=324500=diff
==
--- cfe/trunk/lib/CodeGen/CGDecl.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGDecl.cpp Wed Feb  7 11:16:49 2018
@@ -240,7 +240,7 @@ llvm::Constant *CodeGenModule::getOrCrea
   getModule(), LTy, Ty.isConstant(getContext()), Linkage, Init, Name,
   nullptr, llvm::GlobalVariable::NotThreadLocal, TargetAS);
   GV->setAlignment(getContext().getDeclAlign().getQuantity());
-  setGlobalVisibility(GV, );
+  setGVProperties(GV, );
 
   if (supportsCOMDAT() && GV->isWeakForLinker())
 GV->setComdat(TheModule.getOrInsertComdat(GV->getName()));
@@ -344,6 +344,7 @@ CodeGenFunction::AddInitializerToStaticV
   OldGV->getThreadLocalMode(),

CGM.getContext().getTargetAddressSpace(D.getType()));
 GV->setVisibility(OldGV->getVisibility());
+GV->setDSOLocal(OldGV->isDSOLocal());
 GV->setComdat(OldGV->getComdat());
 
 // Steal the name of the old global

Modified: cfe/trunk/lib/CodeGen/CGVTT.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGVTT.cpp?rev=324500=324499=324500=diff
==
--- cfe/trunk/lib/CodeGen/CGVTT.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGVTT.cpp Wed Feb  7 11:16:49 2018
@@ -100,7 +100,7 @@ CodeGenVTables::EmitVTTDefinition(llvm::
 VTT->setComdat(CGM.getModule().getOrInsertComdat(VTT->getName()));
 
   // Set the right visibility.
-  CGM.setGlobalVisibility(VTT, RD);
+  CGM.setGVProperties(VTT, RD);
 }
 
 llvm::GlobalVariable *CodeGenVTables::GetAddrOfVTT(const CXXRecordDecl *RD) {

Modified: cfe/trunk/lib/CodeGen/CGVTables.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGVTables.cpp?rev=324500=324499=324500=diff
==
--- cfe/trunk/lib/CodeGen/CGVTables.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGVTables.cpp Wed Feb  7 11:16:49 2018
@@ -51,7 +51,7 @@ llvm::Constant *CodeGenModule::GetAddrOf
 
 static void setThunkVisibility(CodeGenModule , const CXXMethodDecl *MD,
const ThunkInfo , llvm::Function *Fn) {
-  CGM.setGlobalVisibility(Fn, MD);
+  CGM.setGVProperties(Fn, MD);
 }
 
 static void setThunkProperties(CodeGenModule , const ThunkInfo ,
@@ -730,7 +730,7 @@ CodeGenVTables::GenerateConstructionVTab
   // Create the variable that will hold the construction vtable.
   llvm::GlobalVariable *VTable =
 CGM.CreateOrReplaceCXXRuntimeVariable(Name, VTType, Linkage);
-  CGM.setGlobalVisibility(VTable, RD);
+  CGM.setGVProperties(VTable, RD);
 
   // V-tables are always unnamed_addr.
   VTable->setUnnamedAddr(llvm::GlobalValue::UnnamedAddr::Global);

Modified: cfe/trunk/lib/CodeGen/CodeGenModule.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenModule.cpp?rev=324500=324499=324500=diff
==
--- 

[PATCH] D42983: [clang-tidy] Add readability-simd-intrinsics check.

2018-02-07 Thread Tim Shen via Phabricator via cfe-commits
timshen added inline comments.



Comment at: clang-tidy/readability/SIMDIntrinsicsCheck.cpp:75
+  // libcxx implementation of std::experimental::simd requires at least C++11.
+  if (!Result.Context->getLangOpts().CPlusPlus11)
+return;

MaskRay wrote:
> lebedev.ri wrote:
> > Is it reasonable to suggest to use ``?
> > I would guess it should be `CPlusPlus2a`
> Added a check-specific option `readability-simd-intrinsics.Experiment`.
> 
> 
> Is it reasonable to suggest to use ?

I think there are two approaches to proceed:
1) We just warn the users, but don't suggest  fixes.
2) We warn and suggest  fixes, but only when a flag is 
turned on (off by default). The flag documentation should clearly include 
"suggest  API".

I'm not sure which one fits better.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D42983



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


[PATCH] D42924: Don't pass ForDefinition_t in places it is redundant.

2018-02-07 Thread Rafael Avila de Espindola via Phabricator via cfe-commits
espindola closed this revision.
espindola added a comment.

r324499


https://reviews.llvm.org/D42924



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


r324499 - Don't pass ForDefinition_t in places it is redundant.

2018-02-07 Thread Rafael Espindola via cfe-commits
Author: rafael
Date: Wed Feb  7 11:04:41 2018
New Revision: 324499

URL: http://llvm.org/viewvc/llvm-project?rev=324499=rev
Log:
Don't pass ForDefinition_t in places it is redundant.

I found this while looking at the ppc failures caused by the dso_local
change.

The issue was that the patch would produce the wrong answer for
available_externally. Having ForDefinition_t available in places where
the code can just check the linkage is a bit of a foot gun.

This patch removes the ForDefiniton_t argument in places where the
linkage is already know.

Modified:
cfe/trunk/lib/CodeGen/CGDecl.cpp
cfe/trunk/lib/CodeGen/CGVTT.cpp
cfe/trunk/lib/CodeGen/CGVTables.cpp
cfe/trunk/lib/CodeGen/CodeGenModule.cpp
cfe/trunk/lib/CodeGen/CodeGenModule.h
cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp
cfe/trunk/lib/CodeGen/TargetInfo.cpp
cfe/trunk/lib/CodeGen/TargetInfo.h

Modified: cfe/trunk/lib/CodeGen/CGDecl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDecl.cpp?rev=324499=324498=324499=diff
==
--- cfe/trunk/lib/CodeGen/CGDecl.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGDecl.cpp Wed Feb  7 11:04:41 2018
@@ -240,7 +240,7 @@ llvm::Constant *CodeGenModule::getOrCrea
   getModule(), LTy, Ty.isConstant(getContext()), Linkage, Init, Name,
   nullptr, llvm::GlobalVariable::NotThreadLocal, TargetAS);
   GV->setAlignment(getContext().getDeclAlign().getQuantity());
-  setGlobalVisibility(GV, , ForDefinition);
+  setGlobalVisibility(GV, );
 
   if (supportsCOMDAT() && GV->isWeakForLinker())
 GV->setComdat(TheModule.getOrInsertComdat(GV->getName()));

Modified: cfe/trunk/lib/CodeGen/CGVTT.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGVTT.cpp?rev=324499=324498=324499=diff
==
--- cfe/trunk/lib/CodeGen/CGVTT.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGVTT.cpp Wed Feb  7 11:04:41 2018
@@ -100,7 +100,7 @@ CodeGenVTables::EmitVTTDefinition(llvm::
 VTT->setComdat(CGM.getModule().getOrInsertComdat(VTT->getName()));
 
   // Set the right visibility.
-  CGM.setGlobalVisibility(VTT, RD, ForDefinition);
+  CGM.setGlobalVisibility(VTT, RD);
 }
 
 llvm::GlobalVariable *CodeGenVTables::GetAddrOfVTT(const CXXRecordDecl *RD) {

Modified: cfe/trunk/lib/CodeGen/CGVTables.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGVTables.cpp?rev=324499=324498=324499=diff
==
--- cfe/trunk/lib/CodeGen/CGVTables.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGVTables.cpp Wed Feb  7 11:04:41 2018
@@ -51,7 +51,7 @@ llvm::Constant *CodeGenModule::GetAddrOf
 
 static void setThunkVisibility(CodeGenModule , const CXXMethodDecl *MD,
const ThunkInfo , llvm::Function *Fn) {
-  CGM.setGlobalVisibility(Fn, MD, ForDefinition);
+  CGM.setGlobalVisibility(Fn, MD);
 }
 
 static void setThunkProperties(CodeGenModule , const ThunkInfo ,
@@ -730,7 +730,7 @@ CodeGenVTables::GenerateConstructionVTab
   // Create the variable that will hold the construction vtable.
   llvm::GlobalVariable *VTable =
 CGM.CreateOrReplaceCXXRuntimeVariable(Name, VTType, Linkage);
-  CGM.setGlobalVisibility(VTable, RD, ForDefinition);
+  CGM.setGlobalVisibility(VTable, RD);
 
   // V-tables are always unnamed_addr.
   VTable->setUnnamedAddr(llvm::GlobalValue::UnnamedAddr::Global);

Modified: cfe/trunk/lib/CodeGen/CodeGenModule.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenModule.cpp?rev=324499=324498=324499=diff
==
--- cfe/trunk/lib/CodeGen/CodeGenModule.cpp (original)
+++ cfe/trunk/lib/CodeGen/CodeGenModule.cpp Wed Feb  7 11:04:41 2018
@@ -700,8 +700,7 @@ llvm::ConstantInt *CodeGenModule::getSiz
 }
 
 void CodeGenModule::setGlobalVisibility(llvm::GlobalValue *GV,
-const NamedDecl *D,
-ForDefinition_t IsForDefinition) const 
{
+const NamedDecl *D) const {
   if (GV->hasDLLImportStorageClass())
 return;
   // Internal definitions always have default visibility.
@@ -712,8 +711,7 @@ void CodeGenModule::setGlobalVisibility(
 
   // Set visibility for definitions.
   LinkageInfo LV = D->getLinkageAndVisibility();
-  if (LV.isVisibilityExplicit() ||
-  (IsForDefinition && !GV->hasAvailableExternallyLinkage()))
+  if (LV.isVisibilityExplicit() || !GV->isDeclarationForLinker())
 GV->setVisibility(GetLLVMVisibility(LV.getVisibility()));
 }
 
@@ -1174,7 +1172,7 @@ void CodeGenModule::SetLLVMFunctionAttri
 void CodeGenModule::SetCommonAttributes(const Decl *D,
 llvm::GlobalValue *GV) {
   if (const auto *ND = dyn_cast_or_null(D))
-setGlobalVisibility(GV, ND, ForDefinition);
+

[PATCH] D43016: Fix for #31362 - ms_abi is implemented incorrectly for larger values (>=16 bytes).

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

lgtm

These ABIInfo classes don't have any state, so just building one on the stack 
as needed is the way to go. Thanks for the fix!


Repository:
  rC Clang

https://reviews.llvm.org/D43016



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


[PATCH] D42983: [clang-tidy] Add readability-simd-intrinsics check.

2018-02-07 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay updated this revision to Diff 133255.
MaskRay marked an inline comment as done.
MaskRay added a comment.

readability-simd-intrinsics.rst


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D42983

Files:
  clang-tidy/readability/CMakeLists.txt
  clang-tidy/readability/ReadabilityTidyModule.cpp
  clang-tidy/readability/SIMDIntrinsicsCheck.cpp
  clang-tidy/readability/SIMDIntrinsicsCheck.h
  docs/ReleaseNotes.rst
  docs/clang-tidy/checks/list.rst
  docs/clang-tidy/checks/readability-simd-intrinsics.rst
  test/clang-tidy/readability-simd-intrinsics.cpp

Index: test/clang-tidy/readability-simd-intrinsics.cpp
===
--- /dev/null
+++ test/clang-tidy/readability-simd-intrinsics.cpp
@@ -0,0 +1,33 @@
+// RUN: %check_clang_tidy %s readability-simd-intrinsics %t
+
+/ X86
+typedef long long __m128i __attribute__((vector_size(16)));
+typedef double __m256 __attribute__((vector_size(32)));
+
+__m128i _mm_add_epi32(__m128i, __m128i);
+__m256 _mm256_load_pd(double const *);
+void _mm256_store_pd(double *, __m256);
+
+int _mm_add_fake(int, int);
+
+void X86() {
+  __m128i i0, i1;
+  __m256 d0;
+
+  _mm_add_epi32(i0, i1);
+// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: '_mm_add_epi32' can be replaced by operator+ on std::experimental::simd objects [readability-simd-intrinsics]
+  d0 = _mm256_load_pd(0);
+  _mm256_store_pd(0, d0);
+
+  _mm_add_fake(0, 1);
+// CHECK-MESSAGES-NOT: :[[@LINE-1]]:
+}
+
+/ PPC
+// vector/__vector requires -maltivec, but this typedef is similar.
+typedef int vector_int __attribute__((vector_size(16)));
+
+vector_int vec_add(vector_int, vector_int);
+
+void PPC() {
+}
Index: docs/clang-tidy/checks/readability-simd-intrinsics.rst
===
--- /dev/null
+++ docs/clang-tidy/checks/readability-simd-intrinsics.rst
@@ -0,0 +1,42 @@
+.. title:: clang-tidy - readability-simd-intrinsics
+
+readability-simd-intrinsics
+===
+
+Finds SIMD intrinsics calls and suggests ``std::experimental::simd`` (`P0214`_) alternatives.
+
+For
+
+.. code-block:: c++
+
+  _mm_add_epi32(a, b);
+
+the check suggests an alternative:
+
+.. code-block:: c++
+
+  simd::experimental::simd::operator+
+
+Many architectures provide SIMD operations (e.g. x86 SSE/AVX, Power AltiVec/VSX,
+ARM NEON). It is common that SIMD code implementing the same algorithm, is
+written in multiple target-dispatching pieces to optimize for different
+architectures or micro-architectures.
+
+The C++ standard proposal `P0214`_ and its extensions cover many common SIMD
+operations. By migrating from target-dependent intrinsics to `P0214` operations,
+the SIMD code can be simplified and pieces for different targets can be unified.
+
+Refer to `P0214`_ for introduction and motivation for the data-parallel standard
+library.
+
+Options
+---
+
+.. option:: Experimental
+
+   If set to zero, the check will be enabled for ``-std=c++2a``. If non-zero,
+   the check will be enabled for ``-std=c++11`` or above (libc++
+   ``std::experimental::simd`` implementation backports `P0214`_ to C++11).
+   Default is ``1``.
+
+.. _P0214: http://wg21.link/p0214
Index: docs/clang-tidy/checks/list.rst
===
--- docs/clang-tidy/checks/list.rst
+++ docs/clang-tidy/checks/list.rst
@@ -216,6 +216,7 @@
readability-redundant-smartptr-get
readability-redundant-string-cstr
readability-redundant-string-init
+   readability-simd-intrinsics
readability-simplify-boolean-expr
readability-static-accessed-through-instance
readability-static-definition-in-anonymous-namespace
Index: docs/ReleaseNotes.rst
===
--- docs/ReleaseNotes.rst
+++ docs/ReleaseNotes.rst
@@ -88,6 +88,12 @@
   Functions that have trailing returns are disallowed, except for those 
   using decltype specifiers and lambda with otherwise unutterable 
   return types.
+
+- New `readability-simd-intrinsics
+  `_ check
+
+  Warns if SIMD intrinsics are used which can be replaced by
+  ``std::experimental::simd`` operations.
 
 - New alias `hicpp-avoid-goto
   `_ to 
Index: clang-tidy/readability/SIMDIntrinsicsCheck.h
===
--- /dev/null
+++ clang-tidy/readability/SIMDIntrinsicsCheck.h
@@ -0,0 +1,41 @@
+//===--- SIMDIntrinsicsCheck.h - clang-tidy--*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#ifndef 

[PATCH] D43017: Clean up use of C allocation functions

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

lgtm


Repository:
  rC Clang

https://reviews.llvm.org/D43017



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


[PATCH] D42887: [Driver] Add option to manually control discarding value names in LLVM IR.

2018-02-07 Thread Eric Fiselier via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC324498: [Driver] Add option to manually control discarding 
value names in LLVM IR. (authored by EricWF, committed by ).

Repository:
  rC Clang

https://reviews.llvm.org/D42887

Files:
  docs/UsersManual.rst
  include/clang/Driver/Options.td
  lib/Driver/ToolChains/Clang.cpp
  test/Driver/clang_f_opts.c


Index: docs/UsersManual.rst
===
--- docs/UsersManual.rst
+++ docs/UsersManual.rst
@@ -1855,6 +1855,27 @@
   must come first.)
 
 
+Controlling LLVM IR Output
+--
+
+Controlling Value Names in LLVM IR
+^^
+
+Emitting value names in LLVM IR increases the size and verbosity of the IR.
+By default, value names are only emitted in assertion-enabled builds of Clang.
+However, when reading IR it can be useful to re-enable the emission of value
+names to improve readability.
+
+.. option:: -fdiscard-value-names
+
+  Discard value names when generating LLVM IR.
+
+.. option:: -fno-discard-value-names
+
+  Do not discard value names when generating LLVM IR. This option can be used
+  to re-enable names for release builds of Clang.
+
+
 Comment Parsing Options
 ---
 
Index: include/clang/Driver/Options.td
===
--- include/clang/Driver/Options.td
+++ include/clang/Driver/Options.td
@@ -790,6 +790,10 @@
 HelpText<"Print a template comparison tree for differing templates">;
 def fdeclspec : Flag<["-"], "fdeclspec">, Group,
   HelpText<"Allow __declspec as a keyword">, Flags<[CC1Option]>;
+def fdiscard_value_names : Flag<["-"], "fdiscard-value-names">, 
Group,
+  HelpText<"Discard value names in LLVM IR">, Flags<[DriverOption]>;
+def fno_discard_value_names : Flag<["-"], "fno-discard-value-names">, 
Group,
+  HelpText<"Do not discard value names in LLVM IR">, Flags<[DriverOption]>;
 def fdollars_in_identifiers : Flag<["-"], "fdollars-in-identifiers">, 
Group,
   HelpText<"Allow '$' in identifiers">, Flags<[CC1Option]>;
 def fdwarf2_cfi_asm : Flag<["-"], "fdwarf2-cfi-asm">, 
Group;
Index: test/Driver/clang_f_opts.c
===
--- test/Driver/clang_f_opts.c
+++ test/Driver/clang_f_opts.c
@@ -517,3 +517,8 @@
 // RUN: %clang -### -S %s 2>&1 | FileCheck 
-check-prefix=CHECK-NO-CF-PROTECTION-BRANCH %s
 // CHECK-CF-PROTECTION-BRANCH: -fcf-protection=branch
 // CHECK-NO-CF-PROTECTION-BRANCH-NOT: -fcf-protection=branch
+
+// RUN: %clang -### -S -fdiscard-value-names %s 2>&1 | FileCheck 
-check-prefix=CHECK-DISCARD-NAMES %s
+// RUN: %clang -### -S -fno-discard-value-names %s 2>&1 | FileCheck 
-check-prefix=CHECK-NO-DISCARD-NAMES %s
+// CHECK-DISCARD-NAMES: "-discard-value-names"
+// CHECK-NO-DISCARD-NAMES-NOT: "-discard-value-names"
Index: lib/Driver/ToolChains/Clang.cpp
===
--- lib/Driver/ToolChains/Clang.cpp
+++ lib/Driver/ToolChains/Clang.cpp
@@ -3266,13 +3266,24 @@
   if (!C.isForDiagnostics())
 CmdArgs.push_back("-disable-free");
 
-// Disable the verification pass in -asserts builds.
 #ifdef NDEBUG
-  CmdArgs.push_back("-disable-llvm-verifier");
-  // Discard LLVM value names in -asserts builds.
-  CmdArgs.push_back("-discard-value-names");
+  const bool IsAssertBuild = false;
+#else
+  const bool IsAssertBuild = true;
 #endif
 
+  // Disable the verification pass in -asserts builds.
+  if (!IsAssertBuild)
+CmdArgs.push_back("disable-llvm-verifier");
+
+  // Discard value names in assert builds unless otherwise specified.
+  if (const Arg *A = Args.getLastArg(options::OPT_fdiscard_value_names,
+ options::OPT_fno_discard_value_names)) {
+if (A->getOption().matches(options::OPT_fdiscard_value_names))
+  CmdArgs.push_back("-discard-value-names");
+  } else if (!IsAssertBuild)
+CmdArgs.push_back("-discard-value-names");
+
   // Set the main file name, so that debug info works even with
   // -save-temps.
   CmdArgs.push_back("-main-file-name");


Index: docs/UsersManual.rst
===
--- docs/UsersManual.rst
+++ docs/UsersManual.rst
@@ -1855,6 +1855,27 @@
   must come first.)
 
 
+Controlling LLVM IR Output
+--
+
+Controlling Value Names in LLVM IR
+^^
+
+Emitting value names in LLVM IR increases the size and verbosity of the IR.
+By default, value names are only emitted in assertion-enabled builds of Clang.
+However, when reading IR it can be useful to re-enable the emission of value
+names to improve readability.
+
+.. option:: -fdiscard-value-names
+
+  Discard value names when generating LLVM IR.
+
+.. option:: -fno-discard-value-names
+
+  Do not discard value names when generating LLVM IR. This option can be used
+  to re-enable names for 

r324498 - [Driver] Add option to manually control discarding value names in LLVM IR.

2018-02-07 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Wed Feb  7 10:36:51 2018
New Revision: 324498

URL: http://llvm.org/viewvc/llvm-project?rev=324498=rev
Log:
[Driver] Add option to manually control discarding value names in LLVM IR.

Summary:
Currently, assertion-disabled Clang builds emit value names when generating 
LLVM IR. This is controlled by the `NDEBUG` macro, and is not easily 
overridable. In order to get IR output containing names from a release build of 
Clang, the user must manually construct the CC1 invocation w/o the 
`-discard-value-names` option. This is less than ideal.

For example, Godbolt uses a release build of Clang, and so when asked to emit 
LLVM IR the result lacks names, making it harder to read. Manually invoking CC1 
on Compiler Explorer is not feasible.

This patch adds the driver options `-fdiscard-value-names` and 
`-fno-discard-value-names` which allow the user to override the default 
behavior. If neither is specified, the old behavior remains.

Reviewers: erichkeane, aaron.ballman, lebedev.ri

Reviewed By: aaron.ballman

Subscribers: bogner, cfe-commits

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

Modified:
cfe/trunk/docs/UsersManual.rst
cfe/trunk/include/clang/Driver/Options.td
cfe/trunk/lib/Driver/ToolChains/Clang.cpp
cfe/trunk/test/Driver/clang_f_opts.c

Modified: cfe/trunk/docs/UsersManual.rst
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/UsersManual.rst?rev=324498=324497=324498=diff
==
--- cfe/trunk/docs/UsersManual.rst (original)
+++ cfe/trunk/docs/UsersManual.rst Wed Feb  7 10:36:51 2018
@@ -1855,6 +1855,27 @@ features. You can "tune" the debug info
   must come first.)
 
 
+Controlling LLVM IR Output
+--
+
+Controlling Value Names in LLVM IR
+^^
+
+Emitting value names in LLVM IR increases the size and verbosity of the IR.
+By default, value names are only emitted in assertion-enabled builds of Clang.
+However, when reading IR it can be useful to re-enable the emission of value
+names to improve readability.
+
+.. option:: -fdiscard-value-names
+
+  Discard value names when generating LLVM IR.
+
+.. option:: -fno-discard-value-names
+
+  Do not discard value names when generating LLVM IR. This option can be used
+  to re-enable names for release builds of Clang.
+
+
 Comment Parsing Options
 ---
 

Modified: cfe/trunk/include/clang/Driver/Options.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Options.td?rev=324498=324497=324498=diff
==
--- cfe/trunk/include/clang/Driver/Options.td (original)
+++ cfe/trunk/include/clang/Driver/Options.td Wed Feb  7 10:36:51 2018
@@ -790,6 +790,10 @@ def fdiagnostics_show_template_tree : Fl
 HelpText<"Print a template comparison tree for differing templates">;
 def fdeclspec : Flag<["-"], "fdeclspec">, Group,
   HelpText<"Allow __declspec as a keyword">, Flags<[CC1Option]>;
+def fdiscard_value_names : Flag<["-"], "fdiscard-value-names">, 
Group,
+  HelpText<"Discard value names in LLVM IR">, Flags<[DriverOption]>;
+def fno_discard_value_names : Flag<["-"], "fno-discard-value-names">, 
Group,
+  HelpText<"Do not discard value names in LLVM IR">, Flags<[DriverOption]>;
 def fdollars_in_identifiers : Flag<["-"], "fdollars-in-identifiers">, 
Group,
   HelpText<"Allow '$' in identifiers">, Flags<[CC1Option]>;
 def fdwarf2_cfi_asm : Flag<["-"], "fdwarf2-cfi-asm">, 
Group;

Modified: cfe/trunk/lib/Driver/ToolChains/Clang.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Clang.cpp?rev=324498=324497=324498=diff
==
--- cfe/trunk/lib/Driver/ToolChains/Clang.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/Clang.cpp Wed Feb  7 10:36:51 2018
@@ -3266,13 +3266,24 @@ void Clang::ConstructJob(Compilation ,
   if (!C.isForDiagnostics())
 CmdArgs.push_back("-disable-free");
 
-// Disable the verification pass in -asserts builds.
 #ifdef NDEBUG
-  CmdArgs.push_back("-disable-llvm-verifier");
-  // Discard LLVM value names in -asserts builds.
-  CmdArgs.push_back("-discard-value-names");
+  const bool IsAssertBuild = false;
+#else
+  const bool IsAssertBuild = true;
 #endif
 
+  // Disable the verification pass in -asserts builds.
+  if (!IsAssertBuild)
+CmdArgs.push_back("disable-llvm-verifier");
+
+  // Discard value names in assert builds unless otherwise specified.
+  if (const Arg *A = Args.getLastArg(options::OPT_fdiscard_value_names,
+ options::OPT_fno_discard_value_names)) {
+if (A->getOption().matches(options::OPT_fdiscard_value_names))
+  CmdArgs.push_back("-discard-value-names");
+  } else if (!IsAssertBuild)
+CmdArgs.push_back("-discard-value-names");
+
   // Set the main file name, so that debug info works even 

[PATCH] D42887: [Driver] Add option to manually control discarding value names in LLVM IR.

2018-02-07 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman accepted this revision.
aaron.ballman added a comment.
This revision is now accepted and ready to land.

LGTM!


https://reviews.llvm.org/D42887



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


[PATCH] D42924: Don't pass ForDefinition_t in places it is redundant.

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

lgtm

I'm guessing things were structured this way so that a function definition 
could have its visibility set before giving it a body, i.e. it would look like 
a declaration, but the visibility should be "for a definition". If everything 
works I suppose we don't do that anymore.


https://reviews.llvm.org/D42924



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


[PATCH] D42887: [Driver] Add option to manually control discarding value names in LLVM IR.

2018-02-07 Thread Eric Fiselier via Phabricator via cfe-commits
EricWF updated this revision to Diff 133251.
EricWF marked an inline comment as done.
EricWF added a comment.

- Fix documentation as requested.
- Put entire statement inside of `#ifdef` blocks.


https://reviews.llvm.org/D42887

Files:
  docs/UsersManual.rst
  include/clang/Driver/Options.td
  lib/Driver/ToolChains/Clang.cpp
  test/Driver/clang_f_opts.c


Index: test/Driver/clang_f_opts.c
===
--- test/Driver/clang_f_opts.c
+++ test/Driver/clang_f_opts.c
@@ -517,3 +517,8 @@
 // RUN: %clang -### -S %s 2>&1 | FileCheck 
-check-prefix=CHECK-NO-CF-PROTECTION-BRANCH %s
 // CHECK-CF-PROTECTION-BRANCH: -fcf-protection=branch
 // CHECK-NO-CF-PROTECTION-BRANCH-NOT: -fcf-protection=branch
+
+// RUN: %clang -### -S -fdiscard-value-names %s 2>&1 | FileCheck 
-check-prefix=CHECK-DISCARD-NAMES %s
+// RUN: %clang -### -S -fno-discard-value-names %s 2>&1 | FileCheck 
-check-prefix=CHECK-NO-DISCARD-NAMES %s
+// CHECK-DISCARD-NAMES: "-discard-value-names"
+// CHECK-NO-DISCARD-NAMES-NOT: "-discard-value-names"
Index: lib/Driver/ToolChains/Clang.cpp
===
--- lib/Driver/ToolChains/Clang.cpp
+++ lib/Driver/ToolChains/Clang.cpp
@@ -3266,13 +3266,24 @@
   if (!C.isForDiagnostics())
 CmdArgs.push_back("-disable-free");
 
-// Disable the verification pass in -asserts builds.
 #ifdef NDEBUG
-  CmdArgs.push_back("-disable-llvm-verifier");
-  // Discard LLVM value names in -asserts builds.
-  CmdArgs.push_back("-discard-value-names");
+  const bool IsAssertBuild = false;
+#else
+  const bool IsAssertBuild = true;
 #endif
 
+  // Disable the verification pass in -asserts builds.
+  if (!IsAssertBuild)
+CmdArgs.push_back("disable-llvm-verifier");
+
+  // Discard value names in assert builds unless otherwise specified.
+  if (const Arg *A = Args.getLastArg(options::OPT_fdiscard_value_names,
+ options::OPT_fno_discard_value_names)) {
+if (A->getOption().matches(options::OPT_fdiscard_value_names))
+  CmdArgs.push_back("-discard-value-names");
+  } else if (!IsAssertBuild)
+CmdArgs.push_back("-discard-value-names");
+
   // Set the main file name, so that debug info works even with
   // -save-temps.
   CmdArgs.push_back("-main-file-name");
Index: include/clang/Driver/Options.td
===
--- include/clang/Driver/Options.td
+++ include/clang/Driver/Options.td
@@ -790,6 +790,10 @@
 HelpText<"Print a template comparison tree for differing templates">;
 def fdeclspec : Flag<["-"], "fdeclspec">, Group,
   HelpText<"Allow __declspec as a keyword">, Flags<[CC1Option]>;
+def fdiscard_value_names : Flag<["-"], "fdiscard-value-names">, 
Group,
+  HelpText<"Discard value names in LLVM IR">, Flags<[DriverOption]>;
+def fno_discard_value_names : Flag<["-"], "fno-discard-value-names">, 
Group,
+  HelpText<"Do not discard value names in LLVM IR">, Flags<[DriverOption]>;
 def fdollars_in_identifiers : Flag<["-"], "fdollars-in-identifiers">, 
Group,
   HelpText<"Allow '$' in identifiers">, Flags<[CC1Option]>;
 def fdwarf2_cfi_asm : Flag<["-"], "fdwarf2-cfi-asm">, 
Group;
Index: docs/UsersManual.rst
===
--- docs/UsersManual.rst
+++ docs/UsersManual.rst
@@ -1855,6 +1855,27 @@
   must come first.)
 
 
+Controlling LLVM IR Output
+--
+
+Controlling Value Names in LLVM IR
+^^
+
+Emitting value names in LLVM IR increases the size and verbosity of the IR.
+By default, value names are only emitted in assertion-enabled builds of Clang.
+However, when reading IR it can be useful to re-enable the emission of value
+names to improve readability.
+
+.. option:: -fdiscard-value-names
+
+  Discard value names when generating LLVM IR.
+
+.. option:: -fno-discard-value-names
+
+  Do not discard value names when generating LLVM IR. This option can be used
+  to re-enable names for release builds of Clang.
+
+
 Comment Parsing Options
 ---
 


Index: test/Driver/clang_f_opts.c
===
--- test/Driver/clang_f_opts.c
+++ test/Driver/clang_f_opts.c
@@ -517,3 +517,8 @@
 // RUN: %clang -### -S %s 2>&1 | FileCheck -check-prefix=CHECK-NO-CF-PROTECTION-BRANCH %s
 // CHECK-CF-PROTECTION-BRANCH: -fcf-protection=branch
 // CHECK-NO-CF-PROTECTION-BRANCH-NOT: -fcf-protection=branch
+
+// RUN: %clang -### -S -fdiscard-value-names %s 2>&1 | FileCheck -check-prefix=CHECK-DISCARD-NAMES %s
+// RUN: %clang -### -S -fno-discard-value-names %s 2>&1 | FileCheck -check-prefix=CHECK-NO-DISCARD-NAMES %s
+// CHECK-DISCARD-NAMES: "-discard-value-names"
+// CHECK-NO-DISCARD-NAMES-NOT: "-discard-value-names"
Index: lib/Driver/ToolChains/Clang.cpp
===
--- lib/Driver/ToolChains/Clang.cpp
+++ 

[PATCH] D42887: [Driver] Add option to manually control discarding value names in LLVM IR.

2018-02-07 Thread Eric Fiselier via Phabricator via cfe-commits
EricWF marked 5 inline comments as done.
EricWF added inline comments.



Comment at: lib/Driver/ToolChains/Clang.cpp:3269-3274
+  const bool IsAssertBuild =
 #ifdef NDEBUG
-  CmdArgs.push_back("-disable-llvm-verifier");
-  // Discard LLVM value names in -asserts builds.
-  CmdArgs.push_back("-discard-value-names");
+  false;
+#else
+  true;
 #endif

bogner wrote:
> It might be a few more characters, but I feel like this is more readable if 
> you put entire statements in the branches of the #if, ie:
> 
> #ifdef NDEBUG
>   const bool IsAssertBuild = false;
> #else
>   const bool IsAssertBuild = true;
> #endif
Ack. Done.



Comment at: test/Driver/clang_f_opts.c:522
+// RUN: %clang -### -S -fdiscard-value-names %s 2>&1 | FileCheck 
-check-prefix=CHECK-DISCARD-NAMES %s
+// RUN: %clang -### -S -fno-discard-value-names %s 2>&1 | FileCheck 
-check-prefix=CHECK-NO-DISCARD-NAMES %s
+// CHECK-DISCARD-NAMES: "-discard-value-names"

lebedev.ri wrote:
> I wonder if it is also possible to check that if neither of 
> `-f[no-]discard-value-names` is specified, what happens.
> The caveat is of course the asserts-vs-no-asserts build type.
I don't think so, at least not easily and without changes to the `lit` 
configuration.

It's gone untested this long, I would love to get this patch in without being 
responsible for adding those tests.



https://reviews.llvm.org/D42887



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


[PATCH] D42895: [libclang] Add `CXSymbolRole role` to CXIdxEntityRefInfo

2018-02-07 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay marked 2 inline comments as done.
MaskRay added inline comments.



Comment at: include/clang-c/Index.h:6159
+   */
+  CXSymbolRole role;
 } CXIdxEntityRefInfo;

ilya-biryukov wrote:
> Why do we need to store both `CXIdxEntityRefKind` and `CXSymbolRole`? Can we 
> store just `CXSymbolRole`?
> Is this for compatibility with existing clients?
> 
> If so, maybe we could:
> - remove `Implicit` and `Direct` from the `CXSymbolRole`
> - keep it only in `CXIdxEntityRefKind`
> - not deprecate the `CXIdxEntityRefKind`
I think `CXIdxEntityRefKind` should be deprecated but for compatibility we do 
not remove the field for this minor version upgrade. But they can be removed 
after a major version upgrade.

For what I have observed, `Implicit` is only used by Objective-C



Comment at: tools/libclang/CXIndexDataConsumer.cpp:154
+  // CXSymbolRole is synchronized with clang::index::SymbolRole.
+  return CXSymbolRole(static_cast(Role));
+}

ilya-biryukov wrote:
> `SymbolRoleSet` seems to have more roles not covered by `CXSymbolRole`.
> Should they be accepted by this function? 
> If yes, maybe zero those bits?
> If no, maybe add an assert?
> 
> 
> The extra roles are:
> ```
>   RelationChildOf = 1 << 9,
>   RelationBaseOf  = 1 << 10,
>   RelationOverrideOf  = 1 << 11,
>   RelationReceivedBy  = 1 << 12,
>   RelationCalledBy= 1 << 13,
>   RelationExtendedBy  = 1 << 14,
>   RelationAccessorOf  = 1 << 15,
>   RelationContainedBy = 1 << 16,
>   RelationIBTypeOf= 1 << 17,
>   RelationSpecializationOf = 1 << 18,
> ```
Yes, it has more relations, but most are only used by Objective-C. In all 
test/Index tests, I have only seen `RelationContainedBy` used for .cpp files. 
Many have not occurred in .m files. So I do not want to expose them, at least 
for now.




Repository:
  rC Clang

https://reviews.llvm.org/D42895



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


[PATCH] D42924: Don't pass ForDefinition_t in places it is redundant.

2018-02-07 Thread Rafael Avila de Espindola via Phabricator via cfe-commits
espindola added a comment.

Ping.


https://reviews.llvm.org/D42924



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


[PATCH] D41992: [libcxx] Avoid spurious construction of valarray elements

2018-02-07 Thread Marshall Clow via Phabricator via cfe-commits
mclow.lists accepted this revision.
mclow.lists added a comment.
This revision is now accepted and ready to land.

This LGTM.




Comment at: include/valarray:3728
+{
+__clear();
 if (__n)

I thought that you had lost an exception guarantee here, but it turns out that 
there wasn't one before.  If the allocation fails, you are left with an empty 
array instead of the old contents.




https://reviews.llvm.org/D41992



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


[PATCH] D42983: [clang-tidy] Add readability-simd-intrinsics check.

2018-02-07 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri added inline comments.



Comment at: clang-tidy/readability/SIMDIntrinsicsCheck.cpp:77
+void SIMDIntrinsicsCheck::registerMatchers(MatchFinder *Finder) {
+  Finder->addMatcher(
+  
callExpr(callee(functionDecl(matchesName("^::(_mm_|_mm256_|_mm512_|vec_)"))),

Eugene.Zelenko wrote:
> MaskRay wrote:
> > Eugene.Zelenko wrote:
> > > You should enable this check only when compiling in appropriate C++ 
> > > version. See getLangOpts() usage in other checks.
> > Thx, I didn't know getLangOpts() before.
> > 
> > I think even in `-x c` mode, `::` is still the prefix of an identifier.
> > 
> >   matchesName("^(_mm_|_mm256_|_mm512_|vec_)")
> > 
> > doesn't match anything but 
> > 
> >   matchesName("^::(_mm_|_mm256_|_mm512_|vec_)")
> > 
> > matches.
> > 
> > verified via `clang-tidy -checks='-*,readability-simd-intrinsics' a.c -- 
> > -xc`
> > 
> Check should be enabled only for C++ version which has 
> std::experimental::simd implementation, so this is why you need to use 
> getLangOpts().
I think this is still not done, 
```
Experimental(Options.getLocalOrGlobal("Experimental", 1) != 0)
```
means it will still be on by default for C++11



Comment at: clang-tidy/readability/SIMDIntrinsicsCheck.cpp:106
+  } else
+return;
+

This logic should be in the beginning of `registerMatchers()`, so this wouldn't 
even be registered/called if it won't do anything.



Comment at: clang-tidy/readability/SIMDIntrinsicsCheck.h:27
+  : ClangTidyCheck(Name, Context),
+Experimental(Options.getLocalOrGlobal("Experimental", 1) != 0) {}
+

I //think// usually this is in `.cpp` file


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D42983



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


[PATCH] D42983: [clang-tidy] Add readability-simd-intrinsics check.

2018-02-07 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay marked 3 inline comments as done.
MaskRay added inline comments.



Comment at: clang-tidy/readability/SIMDIntrinsicsCheck.cpp:26
+
+  static const llvm::StringMap Mapping{
+// [simd.alg]

lebedev.ri wrote:
> You probably want to move `Mapping` out of the function.
Does keeping `  static const llvm::StringMap Mapping{ ... }` 
inside the function avoid a global constructor? The blacklist will surely be 
modified to cover more operations after the revision 



Comment at: clang-tidy/readability/SIMDIntrinsicsCheck.cpp:34
+{"sub", "operator- on std::experimental::simd objects"},
+{"mul", "operator* on std::experimental::simd objects"},
+  };

lebedev.ri wrote:
> To point the obvious, this is not exhaustive list, at least `div` is missing.
Yes, the blacklist will be modified to cover more instructions.

Another fun fact is that though `_mm_div_epi*` are listed in Intel's intrinsics 
guide, no there are no mapping hardware instructions and the functions only 
exist in ICC/ICPC (I guess) not in clang/lib/Headers/*.h



Comment at: clang-tidy/readability/SIMDIntrinsicsCheck.cpp:55
+  // [simd.binary]
+  if (Name.startswith("add_"))
+return "operator+ on std::experimental::simd objects";

lebedev.ri wrote:
> This function was not updated to use the `Mapping` map.
This is because on Power, these functions are overloaded `vec_add` `vec_sub` ...
But on x86, there are suffixes, e.g. `_mm_add_epi32`.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D42983



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


[PATCH] D41629: [libcxx] Improve accuracy of complex asinh and acosh

2018-02-07 Thread Marshall Clow via Phabricator via cfe-commits
mclow.lists added a comment.

This all looks good to me.
I think that one more test should be added - and that's one that tests `__sqr` 
directly.
Since that's not a public routine, the test should go in 
"test/libcxx/numerics/complex.number"


https://reviews.llvm.org/D41629



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


[PATCH] D42983: [clang-tidy] Add readability-simd-intrinsics check.

2018-02-07 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay marked 2 inline comments as done.
MaskRay added inline comments.



Comment at: clang-tidy/readability/SIMDIntrinsicsCheck.cpp:75
+  // libcxx implementation of std::experimental::simd requires at least C++11.
+  if (!Result.Context->getLangOpts().CPlusPlus11)
+return;

lebedev.ri wrote:
> Is it reasonable to suggest to use ``?
> I would guess it should be `CPlusPlus2a`
Added a check-specific option `readability-simd-intrinsics.Experiment`.





Comment at: clang-tidy/readability/SIMDIntrinsicsCheck.cpp:84
+  // SIMD intrinsic call.
+  const FunctionDecl *Callee = Call->getDirectCallee();
+  if (!Callee)

lebedev.ri wrote:
> I would refactor this as astmatcher, at least a local one, e.g. something like
> ```
> AST_MATCHER(CallExpr, hasDirectCallee) {
>   return Node.getDirectCallee();
> }
> ```
> +
> ```
> void SIMDIntrinsicsCheck::registerMatchers(MatchFinder *Finder) {
>   Finder->addMatcher(
>   callExpr(callee(
> +allOf(
>  
> functionDecl(matchesName("^::(_mm_|_mm256_|_mm512_|vec_)")
> +  , hasDirectCallee()
> +)
>)),
>unless(isExpansionInSystemHeader()))
>   .bind("call"),
>   this);
> }
> ```
> Unless of course there is already a narrower that does that
```
AST_MATCHER(CallExpr, hasDirectCallee) {
  return Node.getDirectCallee();
}
```

looks too overkill and I still have to call `Call->getDirectCallee()` in 
`SIMDIntrinsicsCheck::check` and then `Callee->getName()`. I decide to keep it 
as is.


That said, I should also study why `AST_MATCHER(CallExpr, hasDirectCallee)` 
does not compile:
```
../tools/clang/tools/extra/clang-tidy/readability/SIMDIntrinsicsCheck.cpp:95:16:
 error: call to 'callee' is ambiguous
  callExpr(callee(allOf(functionDecl(allOf(
   ^~
../tools/clang/include/clang/ASTMatchers/ASTMatchers.h:2811:25: note: candidate 
function
AST_MATCHER_P(CallExpr, callee, internal::Matcher,
^
../tools/clang/include/clang/ASTMatchers/ASTMatchers.h:2827:34: note: candidate 
function
AST_MATCHER_P_OVERLOAD(CallExpr, callee, internal::Matcher, InnerMatcher,
```



Comment at: clang-tidy/readability/SIMDIntrinsicsCheck.cpp:87
+return;
+  bool IsVector = Callee->getReturnType()->isVectorType();
+  for (const ParmVarDecl *Parm : Callee->parameters()) {

lebedev.ri wrote:
> Same here, i *think* something like this would be better?
> ```
> AST_MATCHER(FunctionDecl, isVectorFunction) {
>  bool IsVector = Node.getReturnType()->isVectorType();
>   for (const ParmVarDecl *Parm : Node.parameters()) {
> QualType Type = Parm->getType();
> if (Type->isPointerType())
>   Type = Type->getPointeeType();
> if (Type->isVectorType())
>   IsVector = true;
> 
>   return IsVector;
> }
> ```
> +
> ```
> void SIMDIntrinsicsCheck::registerMatchers(MatchFinder *Finder) {
>   Finder->addMatcher(
>   callExpr(callee(
> allOf(
>  functionDecl(
> +   allOf(
>  matchesName("^::(_mm_|_mm256_|_mm512_|vec_)")
> + , isVectorFunction()
> +   )
>   , hasDirectCallee()
> )
>)),
>unless(isExpansionInSystemHeader()))
>   .bind("call"),
>   this);
> }
> ```
Thanks! Added isVectorFunction. I guess I may should use unnamed namespace for 
AST_MATCHER, but do I also need the unnamed namespace to enclose TrySuggestPPC 
and TrySuggestX86?


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D42983



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


[PATCH] D42983: [clang-tidy] Add readability-simd-intrinsics check.

2018-02-07 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay updated this revision to Diff 133239.
MaskRay added a comment.

Use unnamed namespace to enclose AST_MATCHER and TrySuggest*


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D42983

Files:
  clang-tidy/readability/CMakeLists.txt
  clang-tidy/readability/ReadabilityTidyModule.cpp
  clang-tidy/readability/SIMDIntrinsicsCheck.cpp
  clang-tidy/readability/SIMDIntrinsicsCheck.h
  docs/ReleaseNotes.rst
  docs/clang-tidy/checks/list.rst
  docs/clang-tidy/checks/readability-simd-intrinsics.rst
  test/clang-tidy/readability-simd-intrinsics.cpp

Index: test/clang-tidy/readability-simd-intrinsics.cpp
===
--- /dev/null
+++ test/clang-tidy/readability-simd-intrinsics.cpp
@@ -0,0 +1,33 @@
+// RUN: %check_clang_tidy %s readability-simd-intrinsics %t
+
+/ X86
+typedef long long __m128i __attribute__((vector_size(16)));
+typedef double __m256 __attribute__((vector_size(32)));
+
+__m128i _mm_add_epi32(__m128i, __m128i);
+__m256 _mm256_load_pd(double const *);
+void _mm256_store_pd(double *, __m256);
+
+int _mm_add_fake(int, int);
+
+void X86() {
+  __m128i i0, i1;
+  __m256 d0;
+
+  _mm_add_epi32(i0, i1);
+// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: '_mm_add_epi32' can be replaced by operator+ on std::experimental::simd objects [readability-simd-intrinsics]
+  d0 = _mm256_load_pd(0);
+  _mm256_store_pd(0, d0);
+
+  _mm_add_fake(0, 1);
+// CHECK-MESSAGES-NOT: :[[@LINE-1]]:
+}
+
+/ PPC
+// vector/__vector requires -maltivec, but this typedef is similar.
+typedef int vector_int __attribute__((vector_size(16)));
+
+vector_int vec_add(vector_int, vector_int);
+
+void PPC() {
+}
Index: docs/clang-tidy/checks/readability-simd-intrinsics.rst
===
--- /dev/null
+++ docs/clang-tidy/checks/readability-simd-intrinsics.rst
@@ -0,0 +1,32 @@
+.. title:: clang-tidy - readability-simd-intrinsics
+
+readability-simd-intrinsics
+===
+
+Finds SIMD intrinsics calls and suggests ``std::experimental::simd`` (`P0214`_) alternatives.
+
+For
+
+.. code-block:: c++
+
+  _mm_add_epi32(a, b);
+
+the check suggests an alternative:
+
+.. code-block:: c++
+
+  simd::experimental::simd::operator+
+
+Many architectures provide SIMD operations (e.g. x86 SSE/AVX, Power AltiVec/VSX,
+ARM NEON). It is common that SIMD code implementing the same algorithm, is
+written in multiple target-dispatching pieces to optimize for different
+architectures or micro-architectures.
+
+The C++ standard proposal `P0214`_ and its extensions cover many common SIMD
+operations. By migrating from target-dependent intrinsics to `P0214` operations,
+the SIMD code can be simplified and pieces for different targets can be unified.
+
+Refer to `P0214`_ for introduction and motivation for the data-parallel standard
+library.
+
+.. _P0214: http://wg21.link/p0214
Index: docs/clang-tidy/checks/list.rst
===
--- docs/clang-tidy/checks/list.rst
+++ docs/clang-tidy/checks/list.rst
@@ -216,6 +216,7 @@
readability-redundant-smartptr-get
readability-redundant-string-cstr
readability-redundant-string-init
+   readability-simd-intrinsics
readability-simplify-boolean-expr
readability-static-accessed-through-instance
readability-static-definition-in-anonymous-namespace
Index: docs/ReleaseNotes.rst
===
--- docs/ReleaseNotes.rst
+++ docs/ReleaseNotes.rst
@@ -88,6 +88,12 @@
   Functions that have trailing returns are disallowed, except for those 
   using decltype specifiers and lambda with otherwise unutterable 
   return types.
+
+- New `readability-simd-intrinsics
+  `_ check
+
+  Warns if SIMD intrinsics are used which can be replaced by
+  ``std::experimental::simd`` operations.
 
 - New alias `hicpp-avoid-goto
   `_ to 
Index: clang-tidy/readability/SIMDIntrinsicsCheck.h
===
--- /dev/null
+++ clang-tidy/readability/SIMDIntrinsicsCheck.h
@@ -0,0 +1,41 @@
+//===--- SIMDIntrinsicsCheck.h - clang-tidy--*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_SIMD_INTRINSICS_CHECK_H
+#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_SIMD_INTRINSICS_CHECK_H
+
+#include "../ClangTidy.h"
+
+namespace clang {
+namespace tidy {
+namespace readability {
+
+/// Find SIMD intrinsics calls and suggest std::experimental::simd alternatives.
+///
+/// For the user-facing documentation see:
+/// 

[PATCH] D42983: [clang-tidy] Add readability-simd-intrinsics check.

2018-02-07 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay updated this revision to Diff 133237.
MaskRay added a comment.

Add check-specific option `Experimental`

  StringRef Std;
  if (Result.Context->getLangOpts().CPlusPlus2a) {
Std = "std";
  } else if (Result.Context->getLangOpts().CPlusPlus11 && Experimental) {
// libcxx implementation backports it to C++11 std::experimental::simd.
Std = "std::experimental";
  } else
return;


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D42983

Files:
  clang-tidy/readability/CMakeLists.txt
  clang-tidy/readability/ReadabilityTidyModule.cpp
  clang-tidy/readability/SIMDIntrinsicsCheck.cpp
  clang-tidy/readability/SIMDIntrinsicsCheck.h
  docs/ReleaseNotes.rst
  docs/clang-tidy/checks/list.rst
  docs/clang-tidy/checks/readability-simd-intrinsics.rst
  test/clang-tidy/readability-simd-intrinsics.cpp

Index: test/clang-tidy/readability-simd-intrinsics.cpp
===
--- /dev/null
+++ test/clang-tidy/readability-simd-intrinsics.cpp
@@ -0,0 +1,33 @@
+// RUN: %check_clang_tidy %s readability-simd-intrinsics %t
+
+/ X86
+typedef long long __m128i __attribute__((vector_size(16)));
+typedef double __m256 __attribute__((vector_size(32)));
+
+__m128i _mm_add_epi32(__m128i, __m128i);
+__m256 _mm256_load_pd(double const *);
+void _mm256_store_pd(double *, __m256);
+
+int _mm_add_fake(int, int);
+
+void X86() {
+  __m128i i0, i1;
+  __m256 d0;
+
+  _mm_add_epi32(i0, i1);
+// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: '_mm_add_epi32' can be replaced by operator+ on std::experimental::simd objects [readability-simd-intrinsics]
+  d0 = _mm256_load_pd(0);
+  _mm256_store_pd(0, d0);
+
+  _mm_add_fake(0, 1);
+// CHECK-MESSAGES-NOT: :[[@LINE-1]]:
+}
+
+/ PPC
+// vector/__vector requires -maltivec, but this typedef is similar.
+typedef int vector_int __attribute__((vector_size(16)));
+
+vector_int vec_add(vector_int, vector_int);
+
+void PPC() {
+}
Index: docs/clang-tidy/checks/readability-simd-intrinsics.rst
===
--- /dev/null
+++ docs/clang-tidy/checks/readability-simd-intrinsics.rst
@@ -0,0 +1,32 @@
+.. title:: clang-tidy - readability-simd-intrinsics
+
+readability-simd-intrinsics
+===
+
+Finds SIMD intrinsics calls and suggests ``std::experimental::simd`` (`P0214`_) alternatives.
+
+For
+
+.. code-block:: c++
+
+  _mm_add_epi32(a, b);
+
+the check suggests an alternative:
+
+.. code-block:: c++
+
+  simd::experimental::simd::operator+
+
+Many architectures provide SIMD operations (e.g. x86 SSE/AVX, Power AltiVec/VSX,
+ARM NEON). It is common that SIMD code implementing the same algorithm, is
+written in multiple target-dispatching pieces to optimize for different
+architectures or micro-architectures.
+
+The C++ standard proposal `P0214`_ and its extensions cover many common SIMD
+operations. By migrating from target-dependent intrinsics to `P0214` operations,
+the SIMD code can be simplified and pieces for different targets can be unified.
+
+Refer to `P0214`_ for introduction and motivation for the data-parallel standard
+library.
+
+.. _P0214: http://wg21.link/p0214
Index: docs/clang-tidy/checks/list.rst
===
--- docs/clang-tidy/checks/list.rst
+++ docs/clang-tidy/checks/list.rst
@@ -216,6 +216,7 @@
readability-redundant-smartptr-get
readability-redundant-string-cstr
readability-redundant-string-init
+   readability-simd-intrinsics
readability-simplify-boolean-expr
readability-static-accessed-through-instance
readability-static-definition-in-anonymous-namespace
Index: docs/ReleaseNotes.rst
===
--- docs/ReleaseNotes.rst
+++ docs/ReleaseNotes.rst
@@ -88,6 +88,12 @@
   Functions that have trailing returns are disallowed, except for those 
   using decltype specifiers and lambda with otherwise unutterable 
   return types.
+
+- New `readability-simd-intrinsics
+  `_ check
+
+  Warns if SIMD intrinsics are used which can be replaced by
+  ``std::experimental::simd`` operations.
 
 - New alias `hicpp-avoid-goto
   `_ to 
Index: clang-tidy/readability/SIMDIntrinsicsCheck.h
===
--- /dev/null
+++ clang-tidy/readability/SIMDIntrinsicsCheck.h
@@ -0,0 +1,41 @@
+//===--- SIMDIntrinsicsCheck.h - clang-tidy--*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_SIMD_INTRINSICS_CHECK_H
+#define 

  1   2   >