[libcxx] r318622 - Fix min/max usage in variant

2017-11-18 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Sat Nov 18 20:57:22 2017
New Revision: 318622

URL: http://llvm.org/viewvc/llvm-project?rev=318622=rev
Log:
Fix min/max usage in variant

Modified:
libcxx/trunk/include/variant

Modified: libcxx/trunk/include/variant
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/variant?rev=318622=318621=318622=diff
==
--- libcxx/trunk/include/variant (original)
+++ libcxx/trunk/include/variant Sat Nov 18 20:57:22 2017
@@ -213,6 +213,9 @@ namespace std {
 #pragma GCC system_header
 #endif
 
+_LIBCPP_PUSH_MACROS
+#include <__undef_macros>
+
 namespace std { // explicitly not using versioning namespace
 
 class _LIBCPP_EXCEPTION_ABI bad_variant_access : public exception {
@@ -1586,4 +1589,6 @@ struct _LIBCPP_TEMPLATE_VIS hashhttp://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[libcxx] r318621 - [libc++] Shrink variant's index type when possible

2017-11-18 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Sat Nov 18 20:19:44 2017
New Revision: 318621

URL: http://llvm.org/viewvc/llvm-project?rev=318621=rev
Log:
[libc++] Shrink variant's index type when possible

Summary:
Currently `std::variant` always uses an unsigned int to store the variant 
index. However this isn't nessesary and causes `std::variant` to be larger than 
it needs to be in most cases.

This patch changes the index type to be `unsigned char` when possible, and 
`unsigned short` or `unsigned int` otherwise, depending on the size (Although 
it's questionable if it's even possible to create a variant with 65535 elements.

Unfortunately this change is an ABI break, and as such is only enabled in ABI 
v2.

Reviewers: mpark

Reviewed By: mpark

Subscribers: cfe-commits

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

Added:

libcxx/trunk/test/libcxx/utilities/variant/variant.variant/variant_size.pass.cpp
Modified:
libcxx/trunk/include/__config
libcxx/trunk/include/variant

Modified: libcxx/trunk/include/__config
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/__config?rev=318621=318620=318621=diff
==
--- libcxx/trunk/include/__config (original)
+++ libcxx/trunk/include/__config Sat Nov 18 20:19:44 2017
@@ -76,9 +76,11 @@
 // its vtable and typeinfo to libc++ rather than having all other libraries
 // using that class define their own copies.
 #define _LIBCPP_ABI_BAD_FUNCTION_CALL_KEY_FUNCTION
-
 // Enable optimized version of __do_get_(un)signed which avoids redundant 
copies.
 #define _LIBCPP_ABI_OPTIMIZED_LOCALE_NUM_GET
+// Use the smallest possible integer type to represent the index of the 
variant.
+// Previously libc++ used "unsigned int" exclusivly.
+#define _LIBCPP_ABI_VARIANT_INDEX_TYPE_OPTIMIZATION
 #elif _LIBCPP_ABI_VERSION == 1
 #if !defined(_LIBCPP_OBJECT_FORMAT_COFF)
 // Enable compiling copies of now inline methods into the dylib to support

Modified: libcxx/trunk/include/variant
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/variant?rev=318621=318620=318621=diff
==
--- libcxx/trunk/include/variant (original)
+++ libcxx/trunk/include/variant Sat Nov 18 20:19:44 2017
@@ -207,6 +207,7 @@ namespace std {
 #include 
 #include 
 #include 
+#include 
 
 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
 #pragma GCC system_header
@@ -283,7 +284,28 @@ struct _LIBCPP_TEMPLATE_VIS variant_alte
 };
 
 constexpr size_t variant_npos = static_cast(-1);
-constexpr unsigned int __variant_npos = static_cast(-1);
+
+constexpr int __choose_index_type(unsigned int __num_elem) {
+  if (__num_elem < std::numeric_limits::max())
+return 0;
+  if (__num_elem < std::numeric_limits::max())
+return 1;
+  return 2;
+}
+
+template 
+using __variant_index_t =
+#ifndef _LIBCPP_ABI_VARIANT_INDEX_TYPE_OPTIMIZATION
+  unsigned int;
+#else
+  std::tuple_element_t<
+  __choose_index_type(_NumAlts),
+  std::tuple
+  >;
+#endif
+
+template 
+constexpr _IndexType __variant_npos = static_cast<_IndexType>(-1);
 
 namespace __find_detail {
 
@@ -647,9 +669,11 @@ _LIBCPP_VARIANT_UNION(_Trait::_Unavailab
 template <_Trait _DestructibleTrait, class... _Types>
 class _LIBCPP_TEMPLATE_VIS __base {
 public:
+  using __index_t = __variant_index_t;
+
   inline _LIBCPP_INLINE_VISIBILITY
   explicit constexpr __base(__valueless_t tag) noexcept
-  : __data(tag), __index(__variant_npos) {}
+  : __data(tag), __index(__variant_npos<__index_t>) {}
 
   template 
   inline _LIBCPP_INLINE_VISIBILITY
@@ -665,7 +689,7 @@ public:
 
   inline _LIBCPP_INLINE_VISIBILITY
   constexpr size_t index() const noexcept {
-return __index == __variant_npos ? variant_npos : __index;
+return __index == __variant_npos<__index_t> ? variant_npos : __index;
   }
 
 protected:
@@ -685,7 +709,7 @@ protected:
   static constexpr size_t __size() { return sizeof...(_Types); }
 
   __union<_DestructibleTrait, 0, _Types...> __data;
-  unsigned int __index;
+  __index_t __index;
 
   friend struct __access::__base;
   friend struct __visitation::__base;
@@ -696,10 +720,11 @@ class _LIBCPP_TEMPLATE_VIS __destructor;
 
 #define _LIBCPP_VARIANT_DESTRUCTOR(destructible_trait, destructor, destroy)
\
   template
\
-  class _LIBCPP_TEMPLATE_VIS __destructor<__traits<_Types...>,\
+  class _LIBCPP_TEMPLATE_VIS __destructor<__traits<_Types...>, 
\
destructible_trait> 
\
   : public __base { 
\
 using __base_type = __base; 
\
+using __index_t = typename __base_type::__index_t; 
\

\
   public:   

r318620 - [X86] Make sure 'knm' is accepted by -target-cpu

2017-11-18 Thread Craig Topper via cfe-commits
Author: ctopper
Date: Sat Nov 18 20:12:35 2017
New Revision: 318620

URL: http://llvm.org/viewvc/llvm-project?rev=318620=rev
Log:
[X86] Make sure 'knm' is accepted by -target-cpu

Modified:
cfe/trunk/test/Frontend/x86-target-cpu.c

Modified: cfe/trunk/test/Frontend/x86-target-cpu.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Frontend/x86-target-cpu.c?rev=318620=318619=318620=diff
==
--- cfe/trunk/test/Frontend/x86-target-cpu.c (original)
+++ cfe/trunk/test/Frontend/x86-target-cpu.c Sat Nov 18 20:12:35 2017
@@ -15,6 +15,7 @@
 // RUN: %clang_cc1 -triple x86_64-unknown-unknown -target-cpu cannonlake 
-verify %s
 // RUN: %clang_cc1 -triple x86_64-unknown-unknown -target-cpu icelake -verify 
%s
 // RUN: %clang_cc1 -triple x86_64-unknown-unknown -target-cpu knl -verify %s
+// RUN: %clang_cc1 -triple x86_64-unknown-unknown -target-cpu knm -verify %s
 // RUN: %clang_cc1 -triple x86_64-unknown-unknown -target-cpu bonnell -verify 
%s
 // RUN: %clang_cc1 -triple x86_64-unknown-unknown -target-cpu silvermont 
-verify %s
 // RUN: %clang_cc1 -triple x86_64-unknown-unknown -target-cpu k8 -verify %s


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


r318619 - [X86] Make sure 'knm' and 'cannonlake' are accepted by builtin_cpu_is

2017-11-18 Thread Craig Topper via cfe-commits
Author: ctopper
Date: Sat Nov 18 20:12:33 2017
New Revision: 318619

URL: http://llvm.org/viewvc/llvm-project?rev=318619=rev
Log:
[X86] Make sure 'knm' and 'cannonlake' are accepted by builtin_cpu_is

Modified:
cfe/trunk/test/CodeGen/target-builtin-noerror.c

Modified: cfe/trunk/test/CodeGen/target-builtin-noerror.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/target-builtin-noerror.c?rev=318619=318618=318619=diff
==
--- cfe/trunk/test/CodeGen/target-builtin-noerror.c (original)
+++ cfe/trunk/test/CodeGen/target-builtin-noerror.c Sat Nov 18 20:12:33 2017
@@ -92,6 +92,7 @@ void verifycpustrings() {
   (void)__builtin_cpu_is("broadwell");
   (void)__builtin_cpu_is("btver1");
   (void)__builtin_cpu_is("btver2");
+  (void)__builtin_cpu_is("cannonlake");
   (void)__builtin_cpu_is("core2");
   (void)__builtin_cpu_is("corei7");
   (void)__builtin_cpu_is("haswell");
@@ -99,6 +100,7 @@ void verifycpustrings() {
   (void)__builtin_cpu_is("istanbul");
   (void)__builtin_cpu_is("ivybridge");
   (void)__builtin_cpu_is("knl");
+  (void)__builtin_cpu_is("knm");
   (void)__builtin_cpu_is("nehalem");
   (void)__builtin_cpu_is("sandybridge");
   (void)__builtin_cpu_is("shanghai");


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


[libcxx] r318618 - Fix nodiscard test when modules are enabled

2017-11-18 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Sat Nov 18 19:50:35 2017
New Revision: 318618

URL: http://llvm.org/viewvc/llvm-project?rev=318618=rev
Log:
Fix nodiscard test when modules are enabled

Modified:
libcxx/trunk/test/libcxx/diagnostics/nodiscard.pass.cpp

Modified: libcxx/trunk/test/libcxx/diagnostics/nodiscard.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/libcxx/diagnostics/nodiscard.pass.cpp?rev=318618=318617=318618=diff
==
--- libcxx/trunk/test/libcxx/diagnostics/nodiscard.pass.cpp (original)
+++ libcxx/trunk/test/libcxx/diagnostics/nodiscard.pass.cpp Sat Nov 18 19:50:35 
2017
@@ -13,6 +13,7 @@
 
 // UNSUPPORTED: c++98, c++03, c++11, c++14
 
+// MODULES_DEFINES: _LIBCPP_DISABLE_NODISCARD_AFTER_CXX17
 #define _LIBCPP_DISABLE_NODISCARD_AFTER_CXX17
 #include <__config>
 


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


[PATCH] D40210: [libc++] Shrink variant's index type when possible

2017-11-18 Thread Eric Fiselier via Phabricator via cfe-commits
EricWF updated this revision to Diff 123492.
EricWF added a comment.

- Address inline comments.


https://reviews.llvm.org/D40210

Files:
  include/__config
  include/variant
  test/libcxx/utilities/variant/variant.variant/variant_size.pass.cpp

Index: test/libcxx/utilities/variant/variant.variant/variant_size.pass.cpp
===
--- /dev/null
+++ test/libcxx/utilities/variant/variant.variant/variant_size.pass.cpp
@@ -0,0 +1,68 @@
+// -*- C++ -*-
+//===--===//
+//
+// 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  class variant;
+
+#include 
+#include 
+#include 
+#include 
+
+template 
+struct make_variant_imp;
+
+template 
+struct make_variant_imp> {
+  using type = std::variant;
+};
+
+template 
+using make_variant_t = typename make_variant_imp::type;
+
+constexpr bool ExpectEqual =
+#ifdef _LIBCPP_ABI_VARIANT_INDEX_TYPE_OPTIMIZATION
+  false;
+#else
+  true;
+#endif
+
+template 
+void test_index_type() {
+  using Lim = std::numeric_limits;
+  using T1 = make_variant_t;
+  using T2 = make_variant_t;
+  static_assert((sizeof(T1) == sizeof(T2)) == ExpectEqual, "");
+}
+
+template 
+void test_index_internals() {
+  using Lim = std::numeric_limits;
+  static_assert(std::__choose_index_type(Lim::max() -1) !=
+std::__choose_index_type(Lim::max()), "");
+  static_assert(std::is_same_v<
+  std::__variant_index_t,
+  std::__variant_index_t
+> == ExpectEqual, "");
+  using IndexT = std::__variant_index_t;
+  using IndexLim = std::numeric_limits;
+  static_assert(std::__variant_npos == IndexLim::max(), "");
+}
+
+int main() {
+  test_index_type();
+  // This won't compile due to template depth issues.
+  //test_index_type();
+  test_index_internals();
+  test_index_internals();
+}
Index: include/variant
===
--- include/variant
+++ include/variant
@@ -207,6 +207,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
 #pragma GCC system_header
@@ -283,7 +284,28 @@
 };
 
 constexpr size_t variant_npos = static_cast(-1);
-constexpr unsigned int __variant_npos = static_cast(-1);
+
+constexpr int __choose_index_type(unsigned int __num_elem) {
+  if (__num_elem < std::numeric_limits::max())
+return 0;
+  if (__num_elem < std::numeric_limits::max())
+return 1;
+  return 2;
+}
+
+template 
+using __variant_index_t =
+#ifndef _LIBCPP_ABI_VARIANT_INDEX_TYPE_OPTIMIZATION
+  unsigned int;
+#else
+  std::tuple_element_t<
+  __choose_index_type(_NumAlts),
+  std::tuple
+  >;
+#endif
+
+template 
+constexpr _IndexType __variant_npos = static_cast<_IndexType>(-1);
 
 namespace __find_detail {
 
@@ -647,9 +669,11 @@
 template <_Trait _DestructibleTrait, class... _Types>
 class _LIBCPP_TEMPLATE_VIS __base {
 public:
+  using __index_t = __variant_index_t;
+
   inline _LIBCPP_INLINE_VISIBILITY
   explicit constexpr __base(__valueless_t tag) noexcept
-  : __data(tag), __index(__variant_npos) {}
+  : __data(tag), __index(__variant_npos<__index_t>) {}
 
   template 
   inline _LIBCPP_INLINE_VISIBILITY
@@ -665,7 +689,7 @@
 
   inline _LIBCPP_INLINE_VISIBILITY
   constexpr size_t index() const noexcept {
-return __index == __variant_npos ? variant_npos : __index;
+return __index == __variant_npos<__index_t> ? variant_npos : __index;
   }
 
 protected:
@@ -685,7 +709,7 @@
   static constexpr size_t __size() { return sizeof...(_Types); }
 
   __union<_DestructibleTrait, 0, _Types...> __data;
-  unsigned int __index;
+  __index_t __index;
 
   friend struct __access::__base;
   friend struct __visitation::__base;
@@ -696,10 +720,11 @@
 
 #define _LIBCPP_VARIANT_DESTRUCTOR(destructible_trait, destructor, destroy)\
   template\
-  class _LIBCPP_TEMPLATE_VIS __destructor<__traits<_Types...>,\
+  class _LIBCPP_TEMPLATE_VIS __destructor<__traits<_Types...>, \
destructible_trait> \
   : public __base { \
 using __base_type = __base; \
+using __index_t = typename __base_type::__index_t; \
\
   public:   

[PATCH] D40210: [libc++] Shrink variant's index type when possible

2017-11-18 Thread Eric Fiselier via Phabricator via cfe-commits
EricWF marked 4 inline comments as done.
EricWF added inline comments.



Comment at: include/variant:300-303
+  std::tuple_element_t<
+  __choose_index_type(_NumElem),
+  std::tuple
+  >;

mpark wrote:
> Could we inline the whole thing and also avoid using the `tuple` utilities?
> We should also add the `#include `
> 
> ```
> conditional_t<
>   (_NumElem < numeric_limits::max()),
>   unsigned char,
>   conditional_t<(_NumElem < numeric_limits::max()),
> unsigned short,
> unsigned int>;
> ```
Not sure that's any cleaner or clearer. Plus it makes it harder to test.

Adding `#include ` as suggested.



Comment at: 
test/libcxx/utilities/variant/variant.variant/variant_size.pass.cpp:52-53
+  using Lim = std::numeric_limits;
+  static_assert(std::__choose_index_type(Lim::max() -1) !=
+std::__choose_index_type(Lim::max()), "");
+  static_assert(std::is_same_v<

mpark wrote:
> I guess I asked you to remove this above. Is this an essential part of the 
> test?
It is a nice part of it. I pushed back on removing the function as noted above. 
Perhaps this can stay then?


https://reviews.llvm.org/D40210



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


[PATCH] D40210: [libc++] Shrink variant's index type when possible

2017-11-18 Thread Michael Park via Phabricator via cfe-commits
mpark added inline comments.



Comment at: include/variant:295
+
+template 
+using __variant_index_t =

`s/_NumElem/_NumAlts/`



Comment at: include/variant:300-303
+  std::tuple_element_t<
+  __choose_index_type(_NumElem),
+  std::tuple
+  >;

Could we inline the whole thing and also avoid using the `tuple` utilities?
We should also add the `#include `

```
conditional_t<
  (_NumElem < numeric_limits::max()),
  unsigned char,
  conditional_t<(_NumElem < numeric_limits::max()),
unsigned short,
unsigned int>;
```



Comment at: include/variant:306
+
+template 
+constexpr _IntType __variant_npos = static_cast<_IntType>(-1);

`s/_IntType/_IndexType/` maybe?



Comment at: 
test/libcxx/utilities/variant/variant.variant/variant_size.pass.cpp:17
+
+#include 
+#include 

Doesn't seem like this is used?



Comment at: 
test/libcxx/utilities/variant/variant.variant/variant_size.pass.cpp:26
+
+template 
+struct make_variant_imp> {

Hm, I see 15 instances of `Indices` and 7 instances of `Indexes`.
Can we use `Indices` everywhere?



Comment at: 
test/libcxx/utilities/variant/variant.variant/variant_size.pass.cpp:52-53
+  using Lim = std::numeric_limits;
+  static_assert(std::__choose_index_type(Lim::max() -1) !=
+std::__choose_index_type(Lim::max()), "");
+  static_assert(std::is_same_v<

I guess I asked you to remove this above. Is this an essential part of the test?


https://reviews.llvm.org/D40210



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


[PATCH] D40221: [clang-format] Parse blocks in braced lists

2017-11-18 Thread strager via Phabricator via cfe-commits
strager created this revision.
Herald added a subscriber: klimek.

clang-format completely ruins the formatting of block literal
expressions which appear inside inside braced initializer lists. For
example:

  int main() {
foo({
  ^() {
return nil;
  }
  });
  }

Teach clang-format to parse blocks inside braced lists:

  int main() {
foo({^() {

return nil;

}});
  }


https://reviews.llvm.org/D40221

Files:
  lib/Format/UnwrappedLineParser.cpp
  lib/Format/UnwrappedLineParser.h
  unittests/Format/FormatTest.cpp

Index: unittests/Format/FormatTest.cpp
===
--- unittests/Format/FormatTest.cpp
+++ unittests/Format/FormatTest.cpp
@@ -11200,6 +11200,85 @@
   verifyFormat("BOOL (^aaa)(void) = ^BOOL {\n"
"};");
 
+  verifyFormat("foo({^{\n"
+   "  return nil;\n"
+   "}});\n");
+  verifyFormat("foo({^() {\n"
+   "  return nil;\n"
+   "}});\n");
+  verifyFormat("foo({^id {\n"
+   "  return nil;\n"
+   "}});\n");
+  verifyFormat("foo({^id() {\n"
+   "  return nil;\n"
+   "}});\n");
+
+  verifyFormat("foo({.cb = ^{\n"
+   "  return nil;\n"
+   "}});\n");
+  verifyFormat("foo({.cb = ^() {\n"
+   "  return nil;\n"
+   "}});\n");
+  verifyFormat("foo({.cb = ^id {\n"
+   "  return nil;\n"
+   "}});\n");
+  verifyFormat("foo({.cb = ^id() {\n"
+   "  return nil;\n"
+   "}});\n");
+
+  verifyFormat("foo(\n"
+   "^{\n"
+   "  return nil;\n"
+   "},\n"
+   "^() {\n"
+   "  return [NSArray new];\n"
+   "});\n");
+  verifyFormat("foo(\n"
+   "^id {\n"
+   "  return nil;\n"
+   "},\n"
+   "^id() {\n"
+   "  return [NSArray new];\n"
+   "});\n");
+
+  verifyFormat("callbacks cbs = {\n"
+   "^{\n"
+   "  return nil;\n"
+   "},\n"
+   "^id {\n"
+   "  return [NSArray new];\n"
+   "},\n"
+   "};");
+  verifyFormat("callbacks cbs = {\n"
+   "^() {\n"
+   "  return nil;\n"
+   "},\n"
+   "^id() {\n"
+   "  return [NSArray new];\n"
+   "},\n"
+   "};");
+
+  verifyFormat("callbacks cbs = {\n"
+   ".cb1 =\n"
+   "^{\n"
+   "  return nil;\n"
+   "},\n"
+   ".cb2 =\n"
+   "^id {\n"
+   "  return [NSArray new];\n"
+   "},\n"
+   "};");
+  verifyFormat("callbacks cbs = {\n"
+   ".cb1 =\n"
+   "^() {\n"
+   "  return nil;\n"
+   "},\n"
+   ".cb2 =\n"
+   "^id() {\n"
+   "  return nil;\n"
+   "},\n"
+   "};");
+
   FormatStyle FourIndent = getLLVMStyle();
   FourIndent.ObjCBlockIndentWidth = 4;
   verifyFormat("[operation setCompletionBlock:^{\n"
Index: lib/Format/UnwrappedLineParser.h
===
--- lib/Format/UnwrappedLineParser.h
+++ lib/Format/UnwrappedLineParser.h
@@ -121,6 +121,7 @@
   void parseObjCInterfaceOrImplementation();
   void parseObjCProtocol();
   void parseJavaScriptEs6ImportExport();
+  bool tryToParseBlock();
   bool tryToParseLambda();
   bool tryToParseLambdaIntroducer();
   void tryToParseJSFunction();
Index: lib/Format/UnwrappedLineParser.cpp
===
--- lib/Format/UnwrappedLineParser.cpp
+++ lib/Format/UnwrappedLineParser.cpp
@@ -1177,14 +1177,7 @@
 nextToken();
   break;
 case tok::caret:
-  nextToken();
-  if (FormatTok->Tok.isAnyIdentifier() ||
-  FormatTok->isSimpleTypeSpecifier())
-nextToken();
-  if (FormatTok->is(tok::l_paren))
-parseParens();
-  if (FormatTok->is(tok::l_brace))
-parseChildBlock();
+  tryToParseBlock();
   break;
 case tok::l_brace:
   if (!tryToParseBracedList()) {
@@ -1311,6 +1304,40 @@
   } while (!eof());
 }
 
+// Parses a block literal expression starting at the initial ^ token.
+//
+// Blocks literal expressions have several forms including the following:
+//
+// \code
+// ^{
+//   return 42;
+// }
+//
+// ^BOOL(int x) {
+//   return x > 0;
+// }
+// \endcode
+bool UnwrappedLineParser::tryToParseBlock() {
+  // Consume the leading ^.
+  assert(FormatTok->is(tok::caret));
+  nextToken();
+  if (!Style.isCpp()) {
+// Blocks are only supported in C++ 

[PATCH] D38824: [X86] Synchronize the existing CPU predefined macros with the cases that gcc defines them

2017-11-18 Thread Craig Topper via Phabricator via cfe-commits
craig.topper abandoned this revision.
craig.topper added a comment.

All skylake-avx512 and cannonlake now set __corei7__ as of r318616. Abandoning 
this.


https://reviews.llvm.org/D38824



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


r318616 - [X86] Set __corei7__ preprocessor defines for skylake server and cannonlake.

2017-11-18 Thread Craig Topper via cfe-commits
Author: ctopper
Date: Sat Nov 18 18:55:14 2017
New Revision: 318616

URL: http://llvm.org/viewvc/llvm-project?rev=318616=rev
Log:
[X86] Set __corei7__ preprocessor defines for skylake server and cannonlake.

This is the resolution we came to in D38824.

Modified:
cfe/trunk/lib/Basic/Targets/X86.cpp
cfe/trunk/test/Preprocessor/predefined-arch-macros.c

Modified: cfe/trunk/lib/Basic/Targets/X86.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets/X86.cpp?rev=318616=318615=318616=diff
==
--- cfe/trunk/lib/Basic/Targets/X86.cpp (original)
+++ cfe/trunk/lib/Basic/Targets/X86.cpp Sat Nov 18 18:55:14 2017
@@ -836,16 +836,13 @@ void X86TargetInfo::getTargetDefines(con
   case CK_Haswell:
   case CK_Broadwell:
   case CK_SkylakeClient:
+  case CK_SkylakeServer:
+  case CK_Cannonlake:
 // FIXME: Historically, we defined this legacy name, it would be nice to
 // remove it at some point. We've never exposed fine-grained names for
 // recent primary x86 CPUs, and we should keep it that way.
 defineCPUMacros(Builder, "corei7");
 break;
-  case CK_SkylakeServer:
-defineCPUMacros(Builder, "skx");
-break;
-  case CK_Cannonlake:
-break;
   case CK_KNL:
 defineCPUMacros(Builder, "knl");
 break;

Modified: cfe/trunk/test/Preprocessor/predefined-arch-macros.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Preprocessor/predefined-arch-macros.c?rev=318616=318615=318616=diff
==
--- cfe/trunk/test/Preprocessor/predefined-arch-macros.c (original)
+++ cfe/trunk/test/Preprocessor/predefined-arch-macros.c Sat Nov 18 18:55:14 
2017
@@ -892,11 +892,11 @@
 // CHECK_SKX_M32: #define __XSAVEOPT__ 1
 // CHECK_SKX_M32: #define __XSAVES__ 1
 // CHECK_SKX_M32: #define __XSAVE__ 1
+// CHECK_SKX_M32: #define __corei7 1
+// CHECK_SKX_M32: #define __corei7__ 1
 // CHECK_SKX_M32: #define __i386 1
 // CHECK_SKX_M32: #define __i386__ 1
-// CHECK_SKX_M32: #define __skx 1
-// CHECK_SKX_M32: #define __skx__ 1
-// CHECK_SKX_M32: #define __tune_skx__ 1
+// CHECK_SKX_M32: #define __tune_corei7__ 1
 // CHECK_SKX_M32: #define i386 1
 
 // RUN: %clang -march=skylake-avx512 -m64 -E -dM %s -o - 2>&1 \
@@ -938,9 +938,9 @@
 // CHECK_SKX_M64: #define __XSAVE__ 1
 // CHECK_SKX_M64: #define __amd64 1
 // CHECK_SKX_M64: #define __amd64__ 1
-// CHECK_SKX_M64: #define __skx 1
-// CHECK_SKX_M64: #define __skx__ 1
-// CHECK_SKX_M64: #define __tune_skx__ 1
+// CHECK_SKX_M64: #define __corei7 1
+// CHECK_SKX_M64: #define __corei7__ 1
+// CHECK_SKX_M64: #define __tune_corei7__ 1
 // CHECK_SKX_M64: #define __x86_64 1
 // CHECK_SKX_M64: #define __x86_64__ 1
 //
@@ -981,8 +981,11 @@
 // CHECK_CNL_M32: #define __XSAVEOPT__ 1
 // CHECK_CNL_M32: #define __XSAVES__ 1
 // CHECK_CNL_M32: #define __XSAVE__ 1
+// CHECK_CNL_M32: #define __corei7 1
+// CHECK_CNL_M32: #define __corei7__ 1
 // CHECK_CNL_M32: #define __i386 1
 // CHECK_CNL_M32: #define __i386__ 1
+// CHECK_CNL_M32: #define __tune_corei7__ 1
 // CHECK_CNL_M32: #define i386 1
 //
 // RUN: %clang -march=cannonlake -m64 -E -dM %s -o - 2>&1 \
@@ -1024,6 +1027,9 @@
 // CHECK_CNL_M64: #define __XSAVE__ 1
 // CHECK_CNL_M64: #define __amd64 1
 // CHECK_CNL_M64: #define __amd64__ 1
+// CHECK_CNL_M64: #define __corei7 1
+// CHECK_CNL_M64: #define __corei7__ 1
+// CHECK_CNL_M64: #define __tune_corei7__ 1
 // CHECK_CNL_M64: #define __x86_64 1
 // CHECK_CNL_M64: #define __x86_64__ 1
 


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


r318617 - [X86] Add icelake CPU support for -march.

2017-11-18 Thread Craig Topper via cfe-commits
Author: ctopper
Date: Sat Nov 18 18:55:15 2017
New Revision: 318617

URL: http://llvm.org/viewvc/llvm-project?rev=318617=rev
Log:
[X86] Add icelake CPU support for -march.

Modified:
cfe/trunk/include/clang/Basic/X86Target.def
cfe/trunk/lib/Basic/Targets/X86.cpp
cfe/trunk/test/Driver/x86-march.c
cfe/trunk/test/Frontend/x86-target-cpu.c
cfe/trunk/test/Preprocessor/predefined-arch-macros.c

Modified: cfe/trunk/include/clang/Basic/X86Target.def
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/X86Target.def?rev=318617=318616=318617=diff
==
--- cfe/trunk/include/clang/Basic/X86Target.def (original)
+++ cfe/trunk/include/clang/Basic/X86Target.def Sat Nov 18 18:55:15 2017
@@ -139,6 +139,10 @@ PROC_ALIAS(SkylakeServer, "skx")
 /// Cannonlake client microarchitecture based processors.
 PROC(Cannonlake, "cannonlake", PROC_64_BIT)
 
+/// \name Icelake Client
+/// Icelake client microarchitecture based processors.
+PROC(Icelake, "icelake", PROC_64_BIT)
+
 /// \name Knights Landing
 /// Knights Landing processor.
 PROC(KNL, "knl", PROC_64_BIT)

Modified: cfe/trunk/lib/Basic/Targets/X86.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets/X86.cpp?rev=318617=318616=318617=diff
==
--- cfe/trunk/lib/Basic/Targets/X86.cpp (original)
+++ cfe/trunk/lib/Basic/Targets/X86.cpp Sat Nov 18 18:55:15 2017
@@ -130,6 +130,9 @@ bool X86TargetInfo::initFeatureMap(
 setFeatureEnabledImpl(Features, "mmx", true);
 break;
 
+  case CK_Icelake:
+// TODO: Add icelake features here.
+LLVM_FALLTHROUGH;
   case CK_Cannonlake:
 setFeatureEnabledImpl(Features, "avx512ifma", true);
 setFeatureEnabledImpl(Features, "avx512vbmi", true);
@@ -838,6 +841,7 @@ void X86TargetInfo::getTargetDefines(con
   case CK_SkylakeClient:
   case CK_SkylakeServer:
   case CK_Cannonlake:
+  case CK_Icelake:
 // FIXME: Historically, we defined this legacy name, it would be nice to
 // remove it at some point. We've never exposed fine-grained names for
 // recent primary x86 CPUs, and we should keep it that way.

Modified: cfe/trunk/test/Driver/x86-march.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/x86-march.c?rev=318617=318616=318617=diff
==
--- cfe/trunk/test/Driver/x86-march.c (original)
+++ cfe/trunk/test/Driver/x86-march.c Sat Nov 18 18:55:15 2017
@@ -60,6 +60,10 @@
 // RUN:   | FileCheck %s -check-prefix=cannonlake
 // cannonlake: "-target-cpu" "cannonlake"
 //
+// RUN: %clang -target x86_64-unknown-unknown -c -### %s -march=icelake 2>&1 \
+// RUN:   | FileCheck %s -check-prefix=icelake
+// icelake: "-target-cpu" "icelake"
+//
 // RUN: %clang -target x86_64-unknown-unknown -c -### %s -march=lakemont 2>&1 \
 // RUN:   | FileCheck %s -check-prefix=lakemont
 // lakemont: "-target-cpu" "lakemont"

Modified: cfe/trunk/test/Frontend/x86-target-cpu.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Frontend/x86-target-cpu.c?rev=318617=318616=318617=diff
==
--- cfe/trunk/test/Frontend/x86-target-cpu.c (original)
+++ cfe/trunk/test/Frontend/x86-target-cpu.c Sat Nov 18 18:55:15 2017
@@ -13,6 +13,7 @@
 // RUN: %clang_cc1 -triple x86_64-unknown-unknown -target-cpu skylake-avx512 
-verify %s
 // RUN: %clang_cc1 -triple x86_64-unknown-unknown -target-cpu skx -verify %s
 // RUN: %clang_cc1 -triple x86_64-unknown-unknown -target-cpu cannonlake 
-verify %s
+// RUN: %clang_cc1 -triple x86_64-unknown-unknown -target-cpu icelake -verify 
%s
 // RUN: %clang_cc1 -triple x86_64-unknown-unknown -target-cpu knl -verify %s
 // RUN: %clang_cc1 -triple x86_64-unknown-unknown -target-cpu bonnell -verify 
%s
 // RUN: %clang_cc1 -triple x86_64-unknown-unknown -target-cpu silvermont 
-verify %s

Modified: cfe/trunk/test/Preprocessor/predefined-arch-macros.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Preprocessor/predefined-arch-macros.c?rev=318617=318616=318617=diff
==
--- cfe/trunk/test/Preprocessor/predefined-arch-macros.c (original)
+++ cfe/trunk/test/Preprocessor/predefined-arch-macros.c Sat Nov 18 18:55:15 
2017
@@ -1033,6 +1033,95 @@
 // CHECK_CNL_M64: #define __x86_64 1
 // CHECK_CNL_M64: #define __x86_64__ 1
 
+// RUN: %clang -march=icelake -m32 -E -dM %s -o - 2>&1 \
+// RUN: -target i386-unknown-linux \
+// RUN:   | FileCheck -match-full-lines %s -check-prefix=CHECK_ICL_M32
+// CHECK_ICL_M32: #define __AES__ 1
+// CHECK_ICL_M32: #define __AVX2__ 1
+// CHECK_ICL_M32: #define __AVX512BW__ 1
+// CHECK_ICL_M32: #define __AVX512CD__ 1
+// CHECK_ICL_M32: #define __AVX512DQ__ 1
+// CHECK_ICL_M32: #define __AVX512F__ 1
+// CHECK_ICL_M32: #define __AVX512IFMA__ 1
+// 

[PATCH] D40115: Driver: remove `SupportsObjCGC`

2017-11-18 Thread Saleem Abdulrasool via Phabricator via cfe-commits
compnerd closed this revision.
compnerd added a comment.

SVN r318609


Repository:
  rL LLVM

https://reviews.llvm.org/D40115



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


[PATCH] D40127: [Driver][ARM] For assembler files recognize -Xassembler or -Wa, -mthumb

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

Would be nice to rename the variable prior to commit.




Comment at: lib/Driver/ToolChain.cpp:549-556
+bool IsIntegratedAssemblerThumb = false;
+for (const Arg *A :
+ Args.filtered(options::OPT_Wa_COMMA, options::OPT_Xassembler)) {
+  for (StringRef Value : A->getValues()) {
+if (Value == "-mthumb")
+  IsIntegratedAssemblerThumb = true;
+  }

peter.smith wrote:
> compnerd wrote:
> > Why not write this as:
> > 
> > const auto  = Args.filtered(options::OPT_Wa_COMMA, 
> > options::OPT_Xassembler);
> > bool IsIntegratedAssemblerThumb =
> > std::any_of(std::begin(A->getValues()),
> > std::end(A->getValues()),
> > [](StringRef Arg) { return Arg == "-mthumb"});
> I gave it a try and I don't think it can be done simply as there are two 
> loops and not one. There could be two Args, one for Wa_COMMA and one for 
> X_Assembler. Unless there is a way of combining the iterator ranges into one 
> I don't think this can be done without nested loops. I checked the other uses 
> of Args.filtered and I couldn't find any of use outside of the range for. 
> Please do let me know if I'm missing something though as I'm happy to change 
> it if there is something better. 
I should've hoisted the `->getValues()`, but I suspect that would work.  But 
that is a slight tweak, not anything to hold this up on.



Comment at: lib/Driver/ToolChain.cpp:547
+// passed to the assember via -Wa or -Xassembler.
+bool IsMThumb = false;
+if (InputType != types::TY_PP_Asm)

I think that this should be `IsThumb`.  The `-m` is just an indicator that this 
is a machine flag.


https://reviews.llvm.org/D40127



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


[PATCH] D39930: [CMake] Use libc++ and compiler-rt as default libraries in Fuchsia toolchain

2017-11-18 Thread Petr Hosek via Phabricator via cfe-commits
phosek added a comment.

This is something I was already thinking about. Ideally, in our toolchain, we 
would build runtimes for all host and target platforms we support, i.e. on 
every host (Linux, macOS and Windows) we would build runtimes for i386, x86_64 
and aarch64 Linux, x86_64 macOS, x86_64 Windows, and x86_64 and aarch64 
Fuchsia. This means that the toolchain on every platform can target every other 
platform as long as you provide the right sysroot. However, there are two 
issues I'm aware of:

1. The compiler-rt build for host is different from the cross-target build: In 
the cross-target build, it only builds artifacts for the specified target 
triple. However, on Linux it always does a multilib build and on macOS it 
produces fat archives for all supported platforms.
2. Clang driver currently assumes that runtimes for host platform live in 
`/lib/`. In Fuchsia, we support runtimes being in 
`/lib/` but no other driver does.

To support what I described above, we would have to move to a setup when host 
platform isn't treated specially as it's today but it's just another triple. 
That's going to require some refactoring and cleanup. @beanz might have some 
opinion on this as well since this is something we already discussed before on 
IRC.


Repository:
  rL LLVM

https://reviews.llvm.org/D39930



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


[PATCH] D40073: [Analyzer] Non-determinism: don't sort indirect goto LabelDecl's by addresses

2017-11-18 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.

Thanks for finding and fixing this!

This looks good, but since the nondeterminism is in CFG construction, I think 
it makes sense to create and dump the CFG rather than running the whole 
analyzer.

Here is a suggestion for a faster, more portable test.

  // RUN: %clang_analyze_cc1 -analyzer-checker=debug.DumpCFG %s 2>&1 | 
FileCheck %s
  
  void *target;
  int indirectBlockSuccessorDeterminism() {
  (void)&
  (void)&
  (void)&
  (void)&
  (void)&
  (void)&
  (void)&
  (void)&
  (void)&
  (void)&
  (void)&
  (void)&
  (void)&
  (void)&
  (void)&
  (void)&
  (void)&
  (void)&
  (void)&
  (void)&
  (void)&
  (void)&
  (void)&
  (void)&
  (void)&
  (void)&
  (void)&
  (void)&
  (void)&
  (void)&
  (void)&
  (void)&
  (void)&
  (void)&
  (void)&
  (void)&
  (void)&
  (void)&
  (void)&
  (void)&
  
  goto *target;
L1:
L2:
L3:
L4:
L5:
L6:
L7:
L8:
L9:
L10:
L11:
L12:
L13:
L14:
L15:
L16:
L17:
L18:
L19:
L20:
L21:
L22:
L23:
L24:
L25:
L26:
L27:
L28:
L29:
L30:
L31:
L32:
L33:
L34:
L35:
L36:
L37:
L38:
L39:
L40:
  return 0;
  }
  
  // CHECK-LABEL:  [B41 (INDIRECT GOTO DISPATCH)]
  // CHECK-NEXT:   Preds (1): B42
  // CHECK-NEXT:  Succs (40): B1 B2 B3 B4 B5 B6 B7 B8
  // CHECK-NEXT:   B9 B10 B11 B12 B13 B14 B15 B16 B17 B18
  // CHECK-NEXT:   B19 B20 B21 B22 B23 B24 B25 B26 B27 B28
  // CHECK-NEXT:   B29 B30 B31 B32 B33 B34 B35 B36 B37 B38
  // CHECK-NEXT:   B39 B40


Repository:
  rL LLVM

https://reviews.llvm.org/D40073



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


r318609 - Driver: remove `SupportsObjCGC` (NFC)

2017-11-18 Thread Saleem Abdulrasool via cfe-commits
Author: compnerd
Date: Sat Nov 18 16:45:33 2017
New Revision: 318609

URL: http://llvm.org/viewvc/llvm-project?rev=318609=rev
Log:
Driver: remove `SupportsObjCGC` (NFC)

This option is not used in the frontend.  Remove the method.

Modified:
cfe/trunk/include/clang/Driver/ToolChain.h
cfe/trunk/lib/Driver/ToolChains/BareMetal.h
cfe/trunk/lib/Driver/ToolChains/Cuda.h
cfe/trunk/lib/Driver/ToolChains/Darwin.cpp
cfe/trunk/lib/Driver/ToolChains/Darwin.h
cfe/trunk/lib/Driver/ToolChains/WebAssembly.cpp
cfe/trunk/lib/Driver/ToolChains/WebAssembly.h

Modified: cfe/trunk/include/clang/Driver/ToolChain.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/ToolChain.h?rev=318609=318608=318609=diff
==
--- cfe/trunk/include/clang/Driver/ToolChain.h (original)
+++ cfe/trunk/include/clang/Driver/ToolChain.h Sat Nov 18 16:45:33 2017
@@ -366,9 +366,6 @@ public:
   /// SupportsProfiling - Does this tool chain support -pg.
   virtual bool SupportsProfiling() const { return true; }
 
-  /// Does this tool chain support Objective-C garbage collection.
-  virtual bool SupportsObjCGC() const { return true; }
-
   /// Complain if this tool chain doesn't support Objective-C ARC.
   virtual void CheckObjCARC() const {}
 

Modified: cfe/trunk/lib/Driver/ToolChains/BareMetal.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/BareMetal.h?rev=318609=318608=318609=diff
==
--- cfe/trunk/lib/Driver/ToolChains/BareMetal.h (original)
+++ cfe/trunk/lib/Driver/ToolChains/BareMetal.h Sat Nov 18 16:45:33 2017
@@ -37,7 +37,6 @@ public:
   bool isPIEDefault() const override { return false; }
   bool isPICDefaultForced() const override { return false; }
   bool SupportsProfiling() const override { return false; }
-  bool SupportsObjCGC() const override { return false; }
 
   RuntimeLibType GetDefaultRuntimeLibType() const override {
 return ToolChain::RLT_CompilerRT;

Modified: cfe/trunk/lib/Driver/ToolChains/Cuda.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Cuda.h?rev=318609=318608=318609=diff
==
--- cfe/trunk/lib/Driver/ToolChains/Cuda.h (original)
+++ cfe/trunk/lib/Driver/ToolChains/Cuda.h Sat Nov 18 16:45:33 2017
@@ -156,7 +156,6 @@ public:
   bool isPIEDefault() const override { return false; }
   bool isPICDefaultForced() const override { return false; }
   bool SupportsProfiling() const override { return false; }
-  bool SupportsObjCGC() const override { return false; }
   bool IsMathErrnoDefault() const override { return false; }
 
   void AddCudaIncludeArgs(const llvm::opt::ArgList ,

Modified: cfe/trunk/lib/Driver/ToolChains/Darwin.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Darwin.cpp?rev=318609=318608=318609=diff
==
--- cfe/trunk/lib/Driver/ToolChains/Darwin.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/Darwin.cpp Sat Nov 18 16:45:33 2017
@@ -2041,8 +2041,6 @@ void Darwin::addStartObjectFileArgs(cons
   }
 }
 
-bool Darwin::SupportsObjCGC() const { return isTargetMacOS(); }
-
 void Darwin::CheckObjCARC() const {
   if (isTargetIOSBased() || isTargetWatchOSBased() ||
   (isTargetMacOS() && !isMacosxVersionLT(10, 6)))

Modified: cfe/trunk/lib/Driver/ToolChains/Darwin.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Darwin.h?rev=318609=318608=318609=diff
==
--- cfe/trunk/lib/Driver/ToolChains/Darwin.h (original)
+++ cfe/trunk/lib/Driver/ToolChains/Darwin.h Sat Nov 18 16:45:33 2017
@@ -245,8 +245,6 @@ public:
 
   bool SupportsProfiling() const override;
 
-  bool SupportsObjCGC() const override { return false; }
-
   bool UseDwarfDebugFlags() const override;
 
   bool UseSjLjExceptions(const llvm::opt::ArgList ) const override {
@@ -455,8 +453,6 @@ public:
 return 0;
   }
 
-  bool SupportsObjCGC() const override;
-
   void CheckObjCARC() const override;
 
   bool UseSjLjExceptions(const llvm::opt::ArgList ) const override;

Modified: cfe/trunk/lib/Driver/ToolChains/WebAssembly.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/WebAssembly.cpp?rev=318609=318608=318609=diff
==
--- cfe/trunk/lib/Driver/ToolChains/WebAssembly.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/WebAssembly.cpp Sat Nov 18 16:45:33 2017
@@ -98,9 +98,6 @@ bool WebAssembly::isPICDefaultForced() c
 
 bool WebAssembly::IsIntegratedAssemblerDefault() const { return true; }
 
-// TODO: Support Objective C stuff.
-bool WebAssembly::SupportsObjCGC() const { return false; }
-
 bool WebAssembly::hasBlocksRuntime() const 

[PATCH] D39588: Distro: initial support for alpine

2017-11-18 Thread Martell Malone via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL318608: [Driver] add initial support for alpine linux 
(authored by martell).

Changed prior to commit:
  https://reviews.llvm.org/D39588?vs=121462=123488#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D39588

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


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


Index: cfe/trunk/include/clang/Driver/Distro.h
===
--- cfe/trunk/include/clang/Driver/Distro.h
+++ cfe/trunk/include/clang/Driver/Distro.h
@@ -26,6 +26,7 @@
 // NB: Releases of a particular Linux distro should be kept together
 // in this enum, because some tests are done by integer comparison against
 // the first and last known member in the family, e.g. IsRedHat().
+AlpineLinux,
 ArchLinux,
 DebianLenny,
 DebianSqueeze,
@@ -116,6 +117,10 @@
 return DistroVal >= UbuntuHardy && DistroVal <= UbuntuBionic;
   }
 
+  bool IsAlpineLinux() const {
+return 

r318608 - [Driver] add initial support for alpine linux

2017-11-18 Thread Martell Malone via cfe-commits
Author: martell
Date: Sat Nov 18 16:08:12 2017
New Revision: 318608

URL: http://llvm.org/viewvc/llvm-project?rev=318608=rev
Log:
[Driver] add initial support for alpine linux

set -pie as default for musl linux targets
add detection of alpine linux
append appropriate compile flags for alpine

Reviewers: rnk

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

Modified:
cfe/trunk/include/clang/Driver/Distro.h
cfe/trunk/lib/Driver/Distro.cpp
cfe/trunk/lib/Driver/ToolChains/Linux.cpp
cfe/trunk/test/Driver/pic.c

Modified: cfe/trunk/include/clang/Driver/Distro.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Distro.h?rev=318608=318607=318608=diff
==
--- cfe/trunk/include/clang/Driver/Distro.h (original)
+++ cfe/trunk/include/clang/Driver/Distro.h Sat Nov 18 16:08:12 2017
@@ -26,6 +26,7 @@ public:
 // NB: Releases of a particular Linux distro should be kept together
 // in this enum, because some tests are done by integer comparison against
 // the first and last known member in the family, e.g. IsRedHat().
+AlpineLinux,
 ArchLinux,
 DebianLenny,
 DebianSqueeze,
@@ -116,6 +117,10 @@ public:
 return DistroVal >= UbuntuHardy && DistroVal <= UbuntuBionic;
   }
 
+  bool IsAlpineLinux() const {
+return DistroVal == AlpineLinux;
+  }
+
   /// @}
 };
 

Modified: cfe/trunk/lib/Driver/Distro.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Distro.cpp?rev=318608=318607=318608=diff
==
--- cfe/trunk/lib/Driver/Distro.cpp (original)
+++ cfe/trunk/lib/Driver/Distro.cpp Sat Nov 18 16:08:12 2017
@@ -129,6 +129,9 @@ static Distro::DistroType DetectDistro(v
   if (VFS.exists("/etc/exherbo-release"))
 return Distro::Exherbo;
 
+  if (VFS.exists("/etc/alpine-release"))
+return Distro::AlpineLinux;
+
   if (VFS.exists("/etc/arch-release"))
 return Distro::ArchLinux;
 

Modified: cfe/trunk/lib/Driver/ToolChains/Linux.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Linux.cpp?rev=318608=318607=318608=diff
==
--- cfe/trunk/lib/Driver/ToolChains/Linux.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/Linux.cpp Sat Nov 18 16:08:12 2017
@@ -210,7 +210,12 @@ Linux::Linux(const Driver , const llvm
 
   Distro Distro(D.getVFS());
 
-  if (Distro.IsOpenSUSE() || Distro.IsUbuntu()) {
+  if (Distro.IsAlpineLinux()) {
+ExtraOpts.push_back("-z");
+ExtraOpts.push_back("now");
+  }
+
+  if (Distro.IsOpenSUSE() || Distro.IsUbuntu() || Distro.IsAlpineLinux()) {
 ExtraOpts.push_back("-z");
 ExtraOpts.push_back("relro");
   }
@@ -232,7 +237,7 @@ Linux::Linux(const Driver , const llvm
   // Android loader does not support .gnu.hash.
   // Hexagon linker/loader does not support .gnu.hash
   if (!IsMips && !IsAndroid && !IsHexagon) {
-if (Distro.IsRedhat() || Distro.IsOpenSUSE() ||
+if (Distro.IsRedhat() || Distro.IsOpenSUSE() || Distro.IsAlpineLinux() ||
 (Distro.IsUbuntu() && Distro >= Distro::UbuntuMaverick))
   ExtraOpts.push_back("--hash-style=gnu");
 
@@ -812,7 +817,7 @@ void Linux::AddIAMCUIncludeArgs(const Ar
 
 bool Linux::isPIEDefault() const {
   return (getTriple().isAndroid() && !getTriple().isAndroidVersionLT(16)) ||
- getSanitizerArgs().requiresPIE();
+  getTriple().isMusl() || getSanitizerArgs().requiresPIE();
 }
 
 SanitizerMask Linux::getSupportedSanitizers() const {

Modified: cfe/trunk/test/Driver/pic.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/pic.c?rev=318608=318607=318608=diff
==
--- cfe/trunk/test/Driver/pic.c (original)
+++ cfe/trunk/test/Driver/pic.c Sat Nov 18 16:08:12 2017
@@ -152,6 +152,22 @@
 // RUN: %clang %s -target i386-unknown-linux -shared -pie -### 2>&1 \
 // RUN:   | FileCheck %s --check-prefix=CHECK-NO-PIE
 //
+// On Musl Linux, PIE is enabled by default, but can be disabled.
+// RUN: %clang -c %s -target x86_64-linux-musl -### 2>&1 \
+// RUN:   | FileCheck %s --check-prefix=CHECK-PIE2
+// RUN: %clang -c %s -target i686-linux-musl -### 2>&1 \
+// RUN:   | FileCheck %s --check-prefix=CHECK-PIE2
+// RUN: %clang -c %s -target armv6-linux-musleabihf -### 2>&1 \
+// RUN:   | FileCheck %s --check-prefix=CHECK-PIE2
+// RUN: %clang -c %s -target armv7-linux-musleabihf -### 2>&1 \
+// RUN:   | FileCheck %s --check-prefix=CHECK-PIE2
+// RUN: %clang %s -target x86_64-linux-musl -nopie -### 2>&1 \
+// RUN:   | FileCheck %s --check-prefix=CHECK-NO-PIE
+// RUN: %clang %s -target x86_64-linux-musl -pie -nopie -### 2>&1 \
+// RUN:   | FileCheck %s --check-prefix=CHECK-NO-PIE
+// RUN: %clang %s -target x86_64-linux-musl -nopie -pie -### 2>&1 \
+// RUN:   | FileCheck %s --check-prefix=CHECK-PIE2
+//
 // Darwin is a 

[PATCH] D40217: [LIT] Fix testing out-of-tree Clang builds

2017-11-18 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.

Accepting for post-commit review. I don't want to be carrying this patch 
locally.


https://reviews.llvm.org/D40217



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


[PATCH] D40144: Implement `std::launder`

2017-11-18 Thread Eric Fiselier via Phabricator via cfe-commits
EricWF added a comment.

I've made an attempt to add `__builtin_launder` to clang in D40218 
.


https://reviews.llvm.org/D40144



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


[PATCH] D37187: [Analyzer] Fix Bug 25609 - Assertion UNREACHABLE: 'Unexpected ProgramPoint' with widen-loops=true

2017-11-18 Thread Devin Coughlin via Phabricator via cfe-commits
dcoughlin added inline comments.



Comment at: lib/StaticAnalyzer/Core/PathDiagnostic.cpp:694
+  } else if (Optional BE = P.getAs()) {
+CFGElement BlockFront = BE->getBlock()->front();
+if (BlockFront.getKind() == CFGElement::Statement) {

MTC wrote:
> szepet wrote:
> > I think it would be more correct to use the location what is used in case 
> > of the BlockEdge. (So on the entranced block terminator condition.) The 
> > reason is because the BlockEntrance display message will be displayed 
> > before the message of the BlockEdge (since it is an "earlier" node in the 
> > ExplodedGraph). So it would result that if check these notes in a viewer 
> > then the earlier note would belong to the later location which could be 
> > confusing.
> Yes, it would be better to use the location of the TerminatorCondition :D.
Thanks for looking into fixing this.

I don't think using the terminator condition of the entered block is the right 
thing to do. The terminator is at the *end* of a basic block and this program 
point represents the entrance to the block. I think it is better to use the 
location corresponding to the first element in in the entered block.


https://reviews.llvm.org/D37187



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


[PATCH] D39673: Toolchain: Normalize dwarf, sjlj and seh eh

2017-11-18 Thread Martell Malone via Phabricator via cfe-commits
martell requested review of this revision.
martell added a comment.

Thanks for the review @rnk . I addressed the comment nit you had.
@mstorsjo  I updated this to also handle thumb on arm.

When doing that I noticed there is something really strange about the existing 
macro defines. I assume they should only be defined when exceptions is enabled.
This is by default in c++ mode of with -fexceptions in c mode.
I moved the defines within a check of exceptions being enabled to address that.

Apple seem to do their own thing for watchOS by just force enabling it for that 
target only.
Some input there would help a lot.

Also if you think we should define the macros even when exceptions are disabled 
could you explain why?


Repository:
  rL LLVM

https://reviews.llvm.org/D39673



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


[PATCH] D39673: Toolchain: Normalize dwarf, sjlj and seh eh

2017-11-18 Thread Martell Malone via Phabricator via cfe-commits
martell updated this revision to Diff 123486.
martell added a comment.
Herald added subscribers: JDevlieghere, javed.absar.

updated to handle dwarf exceptions on arm.


Repository:
  rL LLVM

https://reviews.llvm.org/D39673

Files:
  docs/ClangCommandLineReference.rst
  include/clang/Basic/LangOptions.def
  include/clang/Driver/Options.td
  include/clang/Driver/ToolChain.h
  lib/Basic/Targets/ARM.cpp
  lib/Basic/Targets/OSTargets.h
  lib/Basic/Targets/X86.h
  lib/CodeGen/BackendUtil.cpp
  lib/CodeGen/CGException.cpp
  lib/Driver/ToolChains/Clang.cpp
  lib/Driver/ToolChains/MinGW.cpp
  lib/Driver/ToolChains/MinGW.h
  lib/Frontend/CompilerInvocation.cpp
  lib/Frontend/InitPreprocessor.cpp
  test/CodeGenCXX/mingw-w64-exceptions.c
  test/CodeGenCXX/mingw-w64-seh-exceptions.cpp
  test/Preprocessor/arm-target-features.c
  test/Preprocessor/init.c

Index: test/Preprocessor/init.c
===
--- test/Preprocessor/init.c
+++ test/Preprocessor/init.c
@@ -2381,7 +2381,7 @@
 // ARMV6-CLOUDABI:#define __CloudABI__ 1
 // ARMV6-CLOUDABI:#define __arm__ 1
 
-// RUN: %clang -E -dM -ffreestanding -target arm-netbsd-eabi %s -o - | FileCheck -match-full-lines -check-prefix ARM-NETBSD %s
+// RUN: %clang -E -dM -ffreestanding -fexceptions -target arm-netbsd-eabi %s -o - | FileCheck -match-full-lines -check-prefix ARM-NETBSD %s
 
 // ARM-NETBSD-NOT:#define _LP64
 // ARM-NETBSD:#define __APCS_32__ 1
@@ -2645,7 +2645,7 @@
 // Thumbebv7: #define __THUMB_INTERWORK__ 1
 // Thumbebv7: #define __thumb2__ 1
 
-// RUN: %clang -E -dM -ffreestanding -target thumbv7-pc-mingw32 %s -o - | FileCheck -match-full-lines -check-prefix THUMB-MINGW %s
+// RUN: %clang -E -dM -ffreestanding -fexceptions -target thumbv7-pc-mingw32 %s -o - | FileCheck -match-full-lines -check-prefix THUMB-MINGW %s
 
 // THUMB-MINGW:#define __ARM_DWARF_EH__ 1
 
Index: test/Preprocessor/arm-target-features.c
===
--- test/Preprocessor/arm-target-features.c
+++ test/Preprocessor/arm-target-features.c
@@ -214,6 +214,7 @@
 // A5:#define __ARM_ARCH_7A__ 1
 // A5-NOT:#define __ARM_ARCH_EXT_IDIV__
 // A5:#define __ARM_ARCH_PROFILE 'A'
+// A5-NOT:#define __ARM_DWARF_EH__ 1
 // A5-NOT: #define __ARM_FEATURE_DIRECTED_ROUNDING
 // A5:#define __ARM_FEATURE_DSP 1
 // A5-NOT: #define __ARM_FEATURE_NUMERIC_MAXMIN
@@ -225,6 +226,7 @@
 // A7:#define __ARM_ARCH 7
 // A7:#define __ARM_ARCH_EXT_IDIV__ 1
 // A7:#define __ARM_ARCH_PROFILE 'A'
+// A7-NOT:#define __ARM_DWARF_EH__ 1
 // A7:#define __ARM_FEATURE_DSP 1
 // A7:#define __ARM_FP 0xE
 
Index: test/CodeGenCXX/mingw-w64-seh-exceptions.cpp
===
--- test/CodeGenCXX/mingw-w64-seh-exceptions.cpp
+++ test/CodeGenCXX/mingw-w64-seh-exceptions.cpp
@@ -1,4 +1,5 @@
-// RUN: %clang_cc1 %s -fexceptions -emit-llvm -triple x86_64-w64-windows-gnu -o - | FileCheck %s --check-prefix=X64
+// RUN: %clang_cc1 %s -fexceptions -fseh-exceptions -emit-llvm -triple x86_64-w64-windows-gnu -o - | FileCheck %s --check-prefix=X64
+// RUN: %clang_cc1 %s -fexceptions -fdwarf-exceptions -emit-llvm -triple i686-w64-windows-gnu -o - | FileCheck %s --check-prefix=X86
 // RUN: %clang_cc1 %s -fexceptions -emit-llvm -triple i686-w64-windows-gnu -o - | FileCheck %s --check-prefix=X86
 
 extern "C" void foo();
Index: test/CodeGenCXX/mingw-w64-exceptions.c
===
--- /dev/null
+++ test/CodeGenCXX/mingw-w64-exceptions.c
@@ -0,0 +1,22 @@
+// RUN: %clang -target x86_64-windows-gnu -c %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-SEH
+// RUN: %clang -target i686-windows-gnu -c %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-DWARF
+
+// RUN: %clang -target x86_64-windows-gnu -fsjlj-exceptions -c %s -### 2>&1 | \
+// RUN: FileCheck %s --check-prefix=CHECK-SJLJ
+
+// RUN: %clang -target x86_64-windows-gnu -fdwarf-exceptions -c %s -### 2>&1 | \
+// RUN: FileCheck %s --check-prefix=CHECK-DWARF
+
+// RUN: %clang -target x86_64-windows-gnu -fsjlj-exceptions -fseh-exceptions -c %s -### 2>&1 | \
+// RUN: FileCheck %s --check-prefix=CHECK-SEH
+
+// RUN: %clang -target x86_64-windows-gnu -fseh-exceptions -fsjlj-exceptions -c %s -### 2>&1 | \
+// RUN: FileCheck %s --check-prefix=CHECK-SJLJ
+
+// RUN: %clang -target x86_64-windows-gnu -fseh-exceptions -fdwarf-exceptions -c %s -### 2>&1 | \
+// RUN: FileCheck %s --check-prefix=CHECK-DWARF
+
+// CHECK-SEH: "-fseh-exceptions"
+// CHECK-SJLJ: "-fsjlj-exceptions"
+// CHECK-DWARF-NOT: "-fsjlj-exceptions"
+// CHECK-DWARF-NOT: "-fseh-exceptions"
Index: lib/Frontend/InitPreprocessor.cpp
===
--- lib/Frontend/InitPreprocessor.cpp
+++ lib/Frontend/InitPreprocessor.cpp
@@ -673,12 +673,19 @@
 Builder.defineMacro("__BLOCKS__");
   }
 
-  if (!LangOpts.MSVCCompat && LangOpts.Exceptions)
-Builder.defineMacro("__EXCEPTIONS");
+  if 

[PATCH] D40217: [LIT] Fix testing out-of-tree Clang builds

2017-11-18 Thread Eric Fiselier via Phabricator via cfe-commits
EricWF updated this revision to Diff 123485.
EricWF added a comment.

- Use style suggested by @mgorny.


https://reviews.llvm.org/D40217

Files:
  utils/lit/lit/llvm/config.py


Index: utils/lit/lit/llvm/config.py
===
--- utils/lit/lit/llvm/config.py
+++ utils/lit/lit/llvm/config.py
@@ -367,10 +367,10 @@
 self.clear_environment(possibly_dangerous_env_vars)
 
 # Tweak the PATH to include the tools dir and the scripts dir.
-paths = [self.config.llvm_tools_dir]
-tools = getattr(self.config, 'clang_tools_dir', None)
-if tools:
-paths = paths + [tools]
+# Put Clang first to avoid LLVM from overriding out-of-tree clang 
builds.
+possible_paths = ['clang_tools_dir', 'llvm_tools_dir']
+paths = [getattr(self.config, pp) for pp in possible_paths
+ if getattr(self.config, pp, None)]
 self.with_environment('PATH', paths, append_path=True)
 
 paths = [self.config.llvm_shlib_dir, self.config.llvm_libs_dir]


Index: utils/lit/lit/llvm/config.py
===
--- utils/lit/lit/llvm/config.py
+++ utils/lit/lit/llvm/config.py
@@ -367,10 +367,10 @@
 self.clear_environment(possibly_dangerous_env_vars)
 
 # Tweak the PATH to include the tools dir and the scripts dir.
-paths = [self.config.llvm_tools_dir]
-tools = getattr(self.config, 'clang_tools_dir', None)
-if tools:
-paths = paths + [tools]
+# Put Clang first to avoid LLVM from overriding out-of-tree clang builds.
+possible_paths = ['clang_tools_dir', 'llvm_tools_dir']
+paths = [getattr(self.config, pp) for pp in possible_paths
+ if getattr(self.config, pp, None)]
 self.with_environment('PATH', paths, append_path=True)
 
 paths = [self.config.llvm_shlib_dir, self.config.llvm_libs_dir]
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D39937: [Sema] Improve diagnostics for const- and ref-qualified member functions

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

In https://reviews.llvm.org/D39937#929514, @jtbandes wrote:

> Thanks, will do. Is there an automated system that can run all the tests 
> //before// I merge rather than waiting for a potential build failure after 
> the fact?


You can run the tests locally using llvm-lit, which will get you some coverage 
for your platform and architecture, but that's about the best you can do 
locally.

https://llvm.org/docs/TestingGuide.html#id1


https://reviews.llvm.org/D39937



___
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

2017-11-18 Thread Eric Fiselier via Phabricator via cfe-commits
EricWF updated this revision to Diff 123484.
EricWF added a comment.

- Remove incorrect FIXME comment.


https://reviews.llvm.org/D40218

Files:
  include/clang/Basic/Builtins.def
  include/clang/Basic/DiagnosticSemaKinds.td
  lib/CodeGen/CGBuiltin.cpp
  lib/Sema/SemaChecking.cpp
  test/CodeGen/builtins.c
  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,22 @@
 void synchronize_args() {
   __sync_synchronize(0); // expected-error {{too many arguments}}
 }
+
+#define TEST_TYPE(Ptr, Type) \
+static_assert(__is_same(decltype(__builtin_launder(Ptr)), Type), "expected same type")
+
+void test_builtin_launder(char *p, void *vp, const volatile int *ip, const float*& fp) {
+  int x;
+  __builtin_launder(x); // expected-error {{non-pointer argument to '__builtin_launder'}}
+  TEST_TYPE(p, char*);
+  TEST_TYPE(vp, void*);
+  TEST_TYPE(ip, const volatile int*);
+  TEST_TYPE(fp, const float*);
+  char *d = __builtin_launder(p);
+  void *vd = __builtin_launder(vp);
+  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);
+}
+
+#undef TEST_TYPE
Index: test/Sema/builtins.c
===
--- test/Sema/builtins.c
+++ test/Sema/builtins.c
@@ -248,3 +248,14 @@
 
 return buf;
 }
+
+void test_builtin_launder(char *p, void *vp, const volatile int *ip) {
+  __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'}}
+  char *d = __builtin_launder(p);
+  void *vd = __builtin_launder(vp);
+  const volatile int *id = __builtin_launder(ip);
+  int *id2 = __builtin_launder(ip); // expected-warning {{discards qualifiers}}
+}
Index: test/Preprocessor/feature_tests.c
===
--- test/Preprocessor/feature_tests.c
+++ test/Preprocessor/feature_tests.c
@@ -14,6 +14,7 @@
  !__has_builtin(__builtin_convertvector) || \
  !__has_builtin(__builtin_trap) || \
  !__has_builtin(__c11_atomic_init) || \
+ !__has_builtin(__builtin_launder) || \
  !__has_feature(attribute_analyzer_noreturn) || \
  !__has_feature(attribute_overloadable)
 #error Clang should have these
Index: test/CodeGen/builtins.c
===
--- test/CodeGen/builtins.c
+++ test/CodeGen/builtins.c
@@ -132,6 +132,8 @@
   R(extract_return_addr, ());
   P(signbit, (1.0));
 
+  R(launder, ());
+
   return 0;
 }
 
@@ -396,6 +398,20 @@
   return __builtin_readcyclecounter();
 }
 
+// CHECK-LABEL: define void @test_builtin_launder
+void test_builtin_launder(int *p) {
+  // CHECK: entry
+  // CHECK-NEXT: %p.addr = alloca i32*
+  // CHECK-NEXT: %d = alloca i32*
+  // CHECK-NEXT: store i32* %p, i32** %p.addr, align 8
+  // CHECK-NEXT: [[TMP:%.*]] = load i32*, i32** %p.addr
+  // CHECK-NEXT: [[TMP1:%.*]] = bitcast i32* [[TMP]] to i8*
+  // CHECK-NEXT: [[TMP2:%.*]] = call i8* @llvm.invariant.group.barrier.p0i8(i8* [[TMP1]])
+  // CHECK-NEXT: [[TMP3:%.*]] = bitcast i8* [[TMP2]] to i32*
+  // CHECK-NEXT: store i32* [[TMP3]], i32** %d
+  int *d = __builtin_launder(p);
+}
+
 // Behavior of __builtin_os_log differs between platforms, so only test on X86
 #ifdef __x86_64__
 
Index: lib/Sema/SemaChecking.cpp
===
--- lib/Sema/SemaChecking.cpp
+++ lib/Sema/SemaChecking.cpp
@@ -850,6 +850,19 @@
   return false;
 }
 
+static bool SemaBuiltinLaunder(Sema& S, CallExpr *TheCall) {
+  if (checkArgCount(S, TheCall, 1)) return true;
+  Expr *Arg = TheCall->getArg(0);
+  QualType ArgT = Arg->getType();
+  if (!ArgT->isPointerType()) {
+S.Diag(TheCall->getLocStart(), diag::err_builtin_launder_non_pointer_arg)
+<< TheCall->getSourceRange();
+return true;
+  }
+  TheCall->setType(Arg->getType());
+  return false; // OK
+}
+
 ExprResult
 Sema::CheckBuiltinFunctionCall(FunctionDecl *FDecl, unsigned BuiltinID,
CallExpr *TheCall) {
@@ -967,6 +980,10 @@
 if (checkArgCount(*this, TheCall, 1)) return true;
 TheCall->setType(Context.IntTy);
 break;
+  case Builtin::BI__builtin_launder:
+if (SemaBuiltinLaunder(*this, TheCall))
+  return ExprError();
+break;
   case Builtin::BI__sync_fetch_and_add:
   case Builtin::BI__sync_fetch_and_add_1:
   case Builtin::BI__sync_fetch_and_add_2:
Index: lib/CodeGen/CGBuiltin.cpp

[PATCH] D40218: [Clang] Add __builtin_launder

2017-11-18 Thread Eric Fiselier via Phabricator via cfe-commits
EricWF created this revision.
Herald added a subscriber: Prazek.

This patch adds `__builtin_launder`, which is required to implement 
`std::launder`. Additionally GCC provides `__builtin_launder`, so thing brings 
Clang in-line with GCC.

I'm not exactly sure what magic `__builtin_launder` requires, but  based on 
previous discussions this patch applies a `@llvm.invariant.group.barrier`. As 
noted in previous discussions, this may not be enough to correctly handle 
vtables.


https://reviews.llvm.org/D40218

Files:
  include/clang/Basic/Builtins.def
  include/clang/Basic/DiagnosticSemaKinds.td
  lib/CodeGen/CGBuiltin.cpp
  lib/Sema/SemaChecking.cpp
  test/CodeGen/builtins.c
  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,22 @@
 void synchronize_args() {
   __sync_synchronize(0); // expected-error {{too many arguments}}
 }
+
+#define TEST_TYPE(Ptr, Type) \
+static_assert(__is_same(decltype(__builtin_launder(Ptr)), Type), "expected same type")
+
+void test_builtin_launder(char *p, void *vp, const volatile int *ip, const float*& fp) {
+  int x;
+  __builtin_launder(x); // expected-error {{non-pointer argument to '__builtin_launder'}}
+  TEST_TYPE(p, char*);
+  TEST_TYPE(vp, void*);
+  TEST_TYPE(ip, const volatile int*);
+  TEST_TYPE(fp, const float*);
+  char *d = __builtin_launder(p);
+  void *vd = __builtin_launder(vp);
+  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);
+}
+
+#undef TEST_TYPE
Index: test/Sema/builtins.c
===
--- test/Sema/builtins.c
+++ test/Sema/builtins.c
@@ -248,3 +248,14 @@
 
 return buf;
 }
+
+void test_builtin_launder(char *p, void *vp, const volatile int *ip) {
+  __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'}}
+  char *d = __builtin_launder(p);
+  void *vd = __builtin_launder(vp);
+  const volatile int *id = __builtin_launder(ip);
+  int *id2 = __builtin_launder(ip); // expected-warning {{discards qualifiers}}
+}
Index: test/Preprocessor/feature_tests.c
===
--- test/Preprocessor/feature_tests.c
+++ test/Preprocessor/feature_tests.c
@@ -14,6 +14,7 @@
  !__has_builtin(__builtin_convertvector) || \
  !__has_builtin(__builtin_trap) || \
  !__has_builtin(__c11_atomic_init) || \
+ !__has_builtin(__builtin_launder) || \
  !__has_feature(attribute_analyzer_noreturn) || \
  !__has_feature(attribute_overloadable)
 #error Clang should have these
Index: test/CodeGen/builtins.c
===
--- test/CodeGen/builtins.c
+++ test/CodeGen/builtins.c
@@ -132,6 +132,8 @@
   R(extract_return_addr, ());
   P(signbit, (1.0));
 
+  R(launder, ());
+
   return 0;
 }
 
@@ -396,6 +398,20 @@
   return __builtin_readcyclecounter();
 }
 
+// CHECK-LABEL: define void @test_builtin_launder
+void test_builtin_launder(int *p) {
+  // CHECK: entry
+  // CHECK-NEXT: %p.addr = alloca i32*
+  // CHECK-NEXT: %d = alloca i32*
+  // CHECK-NEXT: store i32* %p, i32** %p.addr, align 8
+  // CHECK-NEXT: [[TMP:%.*]] = load i32*, i32** %p.addr
+  // CHECK-NEXT: [[TMP1:%.*]] = bitcast i32* [[TMP]] to i8*
+  // CHECK-NEXT: [[TMP2:%.*]] = call i8* @llvm.invariant.group.barrier.p0i8(i8* [[TMP1]])
+  // CHECK-NEXT: [[TMP3:%.*]] = bitcast i8* [[TMP2]] to i32*
+  // CHECK-NEXT: store i32* [[TMP3]], i32** %d
+  int *d = __builtin_launder(p);
+}
+
 // Behavior of __builtin_os_log differs between platforms, so only test on X86
 #ifdef __x86_64__
 
Index: lib/Sema/SemaChecking.cpp
===
--- lib/Sema/SemaChecking.cpp
+++ lib/Sema/SemaChecking.cpp
@@ -850,6 +850,20 @@
   return false;
 }
 
+static bool SemaBuiltinLaunder(Sema& S, CallExpr *TheCall) {
+  if (checkArgCount(S, TheCall, 1)) return true;
+  Expr *Arg = TheCall->getArg(0);
+  QualType ArgT = Arg->getType();
+  if (!ArgT->isPointerType()) {
+S.Diag(TheCall->getLocStart(), diag::err_builtin_launder_non_pointer_arg)
+<< TheCall->getSourceRange();
+return true;
+  }
+  TheCall->setType(Arg->getType());
+  // FIXME: Add attributes to argument
+  return false; // OK
+}
+
 ExprResult
 Sema::CheckBuiltinFunctionCall(FunctionDecl *FDecl, unsigned BuiltinID,
CallExpr *TheCall) {
@@ -967,6 +981,10 @@
 if 

[PATCH] D39937: [Sema] Improve diagnostics for const- and ref-qualified member functions

2017-11-18 Thread Jacob Bandes-Storch via Phabricator via cfe-commits
jtbandes added a comment.

Thanks, will do. Is there an automated system that can run all the tests 
//before// I merge rather than waiting for a potential build failure after the 
fact?


https://reviews.llvm.org/D39937



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


[PATCH] D39937: [Sema] Improve diagnostics for const- and ref-qualified member functions

2017-11-18 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.

This LGTM, but you should wait for a few days before committing in case @rsmith 
has comments.


https://reviews.llvm.org/D39937



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


[PATCH] D40217: [LIT] Fix testing out-of-tree Clang builds

2017-11-18 Thread Michał Górny via Phabricator via cfe-commits
mgorny added a comment.

Or even more abstract (if we assume we don't have to check for presence of 
`llvm_tools_dir`):

  path_vars = ['clang_tools_dir', 'llvm_tools_dir']
  paths = [getattr(self.config, k) for k in path_vars if hasattr(self.config, 
k)]

(untested)


https://reviews.llvm.org/D40217



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


[PATCH] D40217: [LIT] Fix testing out-of-tree Clang builds

2017-11-18 Thread Michał Górny via Phabricator via cfe-commits
mgorny added a comment.

To be honest, as I said before, I'm entirely confused by the logic there, with 
all the prepending, appending and shuffling around. But if you believe it gives 
the correct result, I'm all for it.

However, if that wouldn't be too much of a hassle, would you mind also renaming 
the variables to use a bit more meaningful names?

My alternative idea would be to put both paths on the initial list, and filter 
out None instances from the list afterwards, e.g. something like:

  paths = [getattr(self.config, 'clang_tools_dir', None), 
self.config.llvm_tools_dir]
  paths = [x for x in paths if x is not None]


https://reviews.llvm.org/D40217



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


Re: [PATCH] D40217: [LIT] Fix testing out-of-tree Clang builds

2017-11-18 Thread Zachary Turner via cfe-commits
+mgorny

On Sat, Nov 18, 2017 at 2:24 PM Eric Fiselier via Phabricator <
revi...@reviews.llvm.org> wrote:

> EricWF created this revision.
> Herald added a reviewer: modocache.
>
> Currently, LIT configures the LLVM binary path before the Clang binary
> path. However this breaks testing out-of-tree Clang builds (where the LLVM
> binary path includes a copy of Clang).
>
> This patch reverses the order of the paths when looking for Clang, putting
> the Clang binary directory first.
>
>
> https://reviews.llvm.org/D40217
>
> Files:
>   utils/lit/lit/llvm/config.py
>
>
> Index: utils/lit/lit/llvm/config.py
> ===
> --- utils/lit/lit/llvm/config.py
> +++ utils/lit/lit/llvm/config.py
> @@ -369,8 +369,9 @@
>  # Tweak the PATH to include the tools dir and the scripts dir.
>  paths = [self.config.llvm_tools_dir]
>  tools = getattr(self.config, 'clang_tools_dir', None)
> +# Put Clang first to avoid LLVM from overriding out-of-tree clang
> builds.
>  if tools:
> -paths = paths + [tools]
> +paths = [tools] + paths
>  self.with_environment('PATH', paths, append_path=True)
>
>  paths = [self.config.llvm_shlib_dir, self.config.llvm_libs_dir]
>
>
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D39937: [Sema] Improve diagnostics for const- and ref-qualified member functions

2017-11-18 Thread Jacob Bandes-Storch via Phabricator via cfe-commits
jtbandes updated this revision to Diff 123481.
jtbandes added a comment.

- spell out full diagnostic the first time


https://reviews.llvm.org/D39937

Files:
  include/clang/Basic/DiagnosticSemaKinds.td
  lib/Sema/SemaOverload.cpp
  test/CXX/over/over.match/over.match.funcs/p4-0x.cpp
  test/SemaCXX/copy-initialization.cpp

Index: test/SemaCXX/copy-initialization.cpp
===
--- test/SemaCXX/copy-initialization.cpp
+++ test/SemaCXX/copy-initialization.cpp
@@ -26,7 +26,7 @@
 };
 
 // PR3600
-void test(const foo *P) { P->bar(); } // expected-error{{'bar' not viable: 'this' argument has type 'const foo', but function is not marked const}}
+void test(const foo *P) { P->bar(); } // expected-error{{'this' argument to member function 'bar' has type 'const foo', but function is not marked const}}
 
 namespace PR6757 {
   struct Foo {
Index: test/CXX/over/over.match/over.match.funcs/p4-0x.cpp
===
--- test/CXX/over/over.match/over.match.funcs/p4-0x.cpp
+++ test/CXX/over/over.match/over.match.funcs/p4-0x.cpp
@@ -1,5 +1,4 @@
 // RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s
-// expected-no-diagnostics
 
 template T ();
 template T &();
@@ -20,6 +19,18 @@
 
   void g();
 
+  void c() const; // expected-note {{'c' declared here}}
+  void v() volatile; // expected-note {{'v' declared here}}
+  void r() __restrict__; // expected-note {{'r' declared here}}
+  void cr() const __restrict__; // expected-note {{'cr' declared here}}
+  void cv() const volatile;
+  void vr() volatile __restrict__; // expected-note {{'vr' declared here}}
+  void cvr() const volatile __restrict__;
+
+  void lvalue() &; // expected-note 2 {{'lvalue' declared here}}
+  void const_lvalue() const&;
+  void rvalue() &&; // expected-note {{'rvalue' declared here}}
+
   int +(const X0&) &;
   float +(const X0&) &&;
 
@@ -32,7 +43,7 @@
   float () const&&;
 };
 
-void X0::g() {
+void X0::g() { // expected-note {{'g' declared here}}
   int  = f();
   int  = X0::f();
 }
@@ -69,3 +80,26 @@
   float  = xvalue().h2();
   float  = prvalue().h2();
 }
+
+void test_diagnostics(const volatile X0 &__restrict__ cvr) {
+  cvr.g(); // expected-error {{'this' argument to member function 'g' has type 'const volatile X0', but function is not marked const or volatile}}
+  cvr.c(); // expected-error {{not marked volatile}}
+  cvr.v(); // expected-error {{not marked const}}
+  cvr.r(); // expected-error {{not marked const or volatile}}
+  cvr.cr(); // expected-error {{not marked volatile}}
+  cvr.cv();
+  cvr.vr(); // expected-error {{not marked const}}
+  cvr.cvr();
+
+  lvalue().lvalue();
+  lvalue().const_lvalue();
+  lvalue().rvalue(); // expected-error {{'this' argument to member function 'rvalue' is an lvalue, but function has rvalue ref-qualifier}}
+
+  xvalue().lvalue(); // expected-error {{'this' argument to member function 'lvalue' is an rvalue, but function has non-const lvalue ref-qualifier}}
+  xvalue().const_lvalue();
+  xvalue().rvalue();
+
+  prvalue().lvalue(); // expected-error {{'this' argument to member function 'lvalue' is an rvalue, but function has non-const lvalue ref-qualifier}}
+  prvalue().const_lvalue();
+  prvalue().rvalue();
+}
Index: lib/Sema/SemaOverload.cpp
===
--- lib/Sema/SemaOverload.cpp
+++ lib/Sema/SemaOverload.cpp
@@ -5145,7 +5145,8 @@
   *this, From->getLocStart(), From->getType(), FromClassification, Method,
   Method->getParent());
   if (ICS.isBad()) {
-if (ICS.Bad.Kind == BadConversionSequence::bad_qualifiers) {
+switch (ICS.Bad.Kind) {
+case BadConversionSequence::bad_qualifiers: {
   Qualifiers FromQs = FromRecordType.getQualifiers();
   Qualifiers ToQs = DestType.getQualifiers();
   unsigned CVR = FromQs.getCVRQualifiers() & ~ToQs.getCVRQualifiers();
@@ -5158,10 +5159,28 @@
   << Method->getDeclName();
 return ExprError();
   }
+  break;
+}
+
+case BadConversionSequence::lvalue_ref_to_rvalue:
+case BadConversionSequence::rvalue_ref_to_lvalue: {
+  bool IsRValueQualified =
+Method->getRefQualifier() == RefQualifierKind::RQ_RValue;
+  Diag(From->getLocStart(), diag::err_member_function_call_bad_ref)
+<< Method->getDeclName() << FromClassification.isRValue()
+<< IsRValueQualified;
+  Diag(Method->getLocation(), diag::note_previous_decl)
+<< Method->getDeclName();
+  return ExprError();
+}
+
+case BadConversionSequence::no_conversion:
+case BadConversionSequence::unrelated_class:
+  break;
 }
 
 return Diag(From->getLocStart(),
-diag::err_implicit_object_parameter_init)
+diag::err_member_function_call_bad_type)
<< ImplicitParamRecordType << FromRecordType << From->getSourceRange();
   }
 
Index: include/clang/Basic/DiagnosticSemaKinds.td

[PATCH] D39937: [Sema] Improve diagnostics for const- and ref-qualified member functions

2017-11-18 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: test/CXX/over/over.match/over.match.funcs/p4-0x.cpp:85
+void test_diagnostics(const volatile X0 &__restrict__ cvr) {
+  cvr.g(); // expected-error {{not marked const or volatile}}
+  cvr.c(); // expected-error {{not marked volatile}}

You should spell out the entire diagnostic at least the first time it appears 
in the file.


https://reviews.llvm.org/D39937



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


[PATCH] D40217: [LIT] Fix testing out-of-tree Clang builds

2017-11-18 Thread Eric Fiselier via Phabricator via cfe-commits
EricWF created this revision.
Herald added a reviewer: modocache.

Currently, LIT configures the LLVM binary path before the Clang binary path. 
However this breaks testing out-of-tree Clang builds (where the LLVM binary 
path includes a copy of Clang).

This patch reverses the order of the paths when looking for Clang, putting the 
Clang binary directory first.


https://reviews.llvm.org/D40217

Files:
  utils/lit/lit/llvm/config.py


Index: utils/lit/lit/llvm/config.py
===
--- utils/lit/lit/llvm/config.py
+++ utils/lit/lit/llvm/config.py
@@ -369,8 +369,9 @@
 # Tweak the PATH to include the tools dir and the scripts dir.
 paths = [self.config.llvm_tools_dir]
 tools = getattr(self.config, 'clang_tools_dir', None)
+# Put Clang first to avoid LLVM from overriding out-of-tree clang 
builds.
 if tools:
-paths = paths + [tools]
+paths = [tools] + paths
 self.with_environment('PATH', paths, append_path=True)
 
 paths = [self.config.llvm_shlib_dir, self.config.llvm_libs_dir]


Index: utils/lit/lit/llvm/config.py
===
--- utils/lit/lit/llvm/config.py
+++ utils/lit/lit/llvm/config.py
@@ -369,8 +369,9 @@
 # Tweak the PATH to include the tools dir and the scripts dir.
 paths = [self.config.llvm_tools_dir]
 tools = getattr(self.config, 'clang_tools_dir', None)
+# Put Clang first to avoid LLVM from overriding out-of-tree clang builds.
 if tools:
-paths = paths + [tools]
+paths = [tools] + paths
 self.with_environment('PATH', paths, append_path=True)
 
 paths = [self.config.llvm_shlib_dir, self.config.llvm_libs_dir]
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D39937: [Sema] Improve diagnostics for const- and ref-qualified member functions

2017-11-18 Thread Jacob Bandes-Storch via Phabricator via cfe-commits
jtbandes updated this revision to Diff 123476.
jtbandes added a comment.

- feedback from review & more tests


https://reviews.llvm.org/D39937

Files:
  include/clang/Basic/DiagnosticSemaKinds.td
  lib/Sema/SemaOverload.cpp
  test/CXX/over/over.match/over.match.funcs/p4-0x.cpp
  test/SemaCXX/copy-initialization.cpp

Index: test/SemaCXX/copy-initialization.cpp
===
--- test/SemaCXX/copy-initialization.cpp
+++ test/SemaCXX/copy-initialization.cpp
@@ -26,7 +26,7 @@
 };
 
 // PR3600
-void test(const foo *P) { P->bar(); } // expected-error{{'bar' not viable: 'this' argument has type 'const foo', but function is not marked const}}
+void test(const foo *P) { P->bar(); } // expected-error{{'this' argument to member function 'bar' has type 'const foo', but function is not marked const}}
 
 namespace PR6757 {
   struct Foo {
Index: test/CXX/over/over.match/over.match.funcs/p4-0x.cpp
===
--- test/CXX/over/over.match/over.match.funcs/p4-0x.cpp
+++ test/CXX/over/over.match/over.match.funcs/p4-0x.cpp
@@ -1,5 +1,4 @@
 // RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s
-// expected-no-diagnostics
 
 template T ();
 template T &();
@@ -20,6 +19,18 @@
 
   void g();
 
+  void c() const; // expected-note {{'c' declared here}}
+  void v() volatile; // expected-note {{'v' declared here}}
+  void r() __restrict__; // expected-note {{'r' declared here}}
+  void cr() const __restrict__; // expected-note {{'cr' declared here}}
+  void cv() const volatile;
+  void vr() volatile __restrict__; // expected-note {{'vr' declared here}}
+  void cvr() const volatile __restrict__;
+
+  void lvalue() &; // expected-note 2 {{'lvalue' declared here}}
+  void const_lvalue() const&;
+  void rvalue() &&; // expected-note {{'rvalue' declared here}}
+
   int +(const X0&) &;
   float +(const X0&) &&;
 
@@ -32,7 +43,7 @@
   float () const&&;
 };
 
-void X0::g() {
+void X0::g() { // expected-note {{'g' declared here}}
   int  = f();
   int  = X0::f();
 }
@@ -69,3 +80,26 @@
   float  = xvalue().h2();
   float  = prvalue().h2();
 }
+
+void test_diagnostics(const volatile X0 &__restrict__ cvr) {
+  cvr.g(); // expected-error {{not marked const or volatile}}
+  cvr.c(); // expected-error {{not marked volatile}}
+  cvr.v(); // expected-error {{not marked const}}
+  cvr.r(); // expected-error {{not marked const or volatile}}
+  cvr.cr(); // expected-error {{not marked volatile}}
+  cvr.cv();
+  cvr.vr(); // expected-error {{not marked const}}
+  cvr.cvr();
+
+  lvalue().lvalue();
+  lvalue().const_lvalue();
+  lvalue().rvalue(); // expected-error {{'this' argument to member function 'rvalue' is an lvalue, but function has rvalue ref-qualifier}}
+
+  xvalue().lvalue(); // expected-error {{'this' argument to member function 'lvalue' is an rvalue, but function has non-const lvalue ref-qualifier}}
+  xvalue().const_lvalue();
+  xvalue().rvalue();
+
+  prvalue().lvalue(); // expected-error {{'this' argument to member function 'lvalue' is an rvalue, but function has non-const lvalue ref-qualifier}}
+  prvalue().const_lvalue();
+  prvalue().rvalue();
+}
Index: lib/Sema/SemaOverload.cpp
===
--- lib/Sema/SemaOverload.cpp
+++ lib/Sema/SemaOverload.cpp
@@ -5145,7 +5145,8 @@
   *this, From->getLocStart(), From->getType(), FromClassification, Method,
   Method->getParent());
   if (ICS.isBad()) {
-if (ICS.Bad.Kind == BadConversionSequence::bad_qualifiers) {
+switch (ICS.Bad.Kind) {
+case BadConversionSequence::bad_qualifiers: {
   Qualifiers FromQs = FromRecordType.getQualifiers();
   Qualifiers ToQs = DestType.getQualifiers();
   unsigned CVR = FromQs.getCVRQualifiers() & ~ToQs.getCVRQualifiers();
@@ -5158,10 +5159,28 @@
   << Method->getDeclName();
 return ExprError();
   }
+  break;
+}
+
+case BadConversionSequence::lvalue_ref_to_rvalue:
+case BadConversionSequence::rvalue_ref_to_lvalue: {
+  bool IsRValueQualified =
+Method->getRefQualifier() == RefQualifierKind::RQ_RValue;
+  Diag(From->getLocStart(), diag::err_member_function_call_bad_ref)
+<< Method->getDeclName() << FromClassification.isRValue()
+<< IsRValueQualified;
+  Diag(Method->getLocation(), diag::note_previous_decl)
+<< Method->getDeclName();
+  return ExprError();
+}
+
+case BadConversionSequence::no_conversion:
+case BadConversionSequence::unrelated_class:
+  break;
 }
 
 return Diag(From->getLocStart(),
-diag::err_implicit_object_parameter_init)
+diag::err_member_function_call_bad_type)
<< ImplicitParamRecordType << FromRecordType << From->getSourceRange();
   }
 
Index: include/clang/Basic/DiagnosticSemaKinds.td
===
--- include/clang/Basic/DiagnosticSemaKinds.td
+++ 

[PATCH] D39027: [docs][refactor] Add a new tutorial that talks about how one can implement refactoring actions

2017-11-18 Thread Jonas Toth via Phabricator via cfe-commits
JonasToth added inline comments.



Comment at: docs/RefactoringActionTutorial.rst:236
+  class NestedIfSelectionRequirement final
+  : final CodeRangeSelectionRequirement {
+  public:

i think the `final` after the colon should be `public` instead.


Repository:
  rL LLVM

https://reviews.llvm.org/D39027



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


[PATCH] D39505: [OpenMP] Show error if VLAs are not supported

2017-11-18 Thread Jonas Hahnfeld via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Hahnfeld marked an inline comment as done.
Closed by commit rL318601: [OpenMP] Show error if VLAs are not supported 
(authored by Hahnfeld).

Changed prior to commit:
  https://reviews.llvm.org/D39505?vs=123364=123473#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D39505

Files:
  cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
  cfe/trunk/include/clang/Basic/TargetInfo.h
  cfe/trunk/include/clang/Sema/Sema.h
  cfe/trunk/lib/Basic/TargetInfo.cpp
  cfe/trunk/lib/Basic/Targets/NVPTX.cpp
  cfe/trunk/lib/Basic/Targets/SPIR.h
  cfe/trunk/lib/Sema/SemaOpenMP.cpp
  cfe/trunk/lib/Sema/SemaType.cpp
  cfe/trunk/test/OpenMP/target_vla_messages.cpp

Index: cfe/trunk/include/clang/Sema/Sema.h
===
--- cfe/trunk/include/clang/Sema/Sema.h
+++ cfe/trunk/include/clang/Sema/Sema.h
@@ -8653,10 +8653,18 @@
 NamedDeclSetType );
   /// Check declaration inside target region.
   void checkDeclIsAllowedInOpenMPTarget(Expr *E, Decl *D);
-  /// Return true inside OpenMP target region.
+  /// Return true inside OpenMP declare target region.
   bool isInOpenMPDeclareTargetContext() const {
 return IsInOpenMPDeclareTargetContext;
   }
+  /// Return true inside OpenMP target region.
+  bool isInOpenMPTargetExecutionDirective() const;
+  /// Return true if (un)supported features for the current target should be
+  /// diagnosed if OpenMP (offloading) is enabled.
+  bool shouldDiagnoseTargetSupportFromOpenMP() const {
+return !getLangOpts().OpenMPIsDevice || isInOpenMPDeclareTargetContext() ||
+  isInOpenMPTargetExecutionDirective();
+  }
 
   /// Return the number of captured regions created for an OpenMP directive.
   static int getOpenMPCaptureLevels(OpenMPDirectiveKind Kind);
Index: cfe/trunk/include/clang/Basic/TargetInfo.h
===
--- cfe/trunk/include/clang/Basic/TargetInfo.h
+++ cfe/trunk/include/clang/Basic/TargetInfo.h
@@ -60,6 +60,7 @@
   // values are specified by the TargetInfo constructor.
   bool BigEndian;
   bool TLSSupported;
+  bool VLASupported;
   bool NoAsmVariants;  // True if {|} are normal characters.
   bool HasFloat128;
   unsigned char PointerWidth, PointerAlign;
@@ -939,6 +940,9 @@
 return MaxTLSAlign;
   }
 
+  /// \brief Whether target supports variable-length arrays.
+  bool isVLASupported() const { return VLASupported; }
+
   /// \brief Whether the target supports SEH __try.
   bool isSEHTrySupported() const {
 return getTriple().isOSWindows() &&
Index: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
===
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
@@ -141,6 +141,10 @@
   "variable length array declaration cannot have 'extern' linkage">;
 def ext_vla_folded_to_constant : Extension<
   "variable length array folded to constant array as an extension">, InGroup;
+def err_vla_unsupported : Error<
+  "variable length arrays are not supported for the current target">;
+def note_vla_unsupported : Note<
+  "variable length arrays are not supported for the current target">;
 
 // C99 variably modified types
 def err_variably_modified_template_arg : Error<
@@ -8985,6 +8989,8 @@
   "expected addressable reduction item for the task-based directives">;
 def err_omp_reduction_with_nogroup : Error<
   "'reduction' clause cannot be used with 'nogroup' clause">;
+def err_omp_reduction_vla_unsupported : Error<
+  "cannot generate code for reduction on %select{|array section, which requires a }0variable length array">;
 } // end of OpenMP category
 
 let CategoryName = "Related Result Type Issue" in {
Index: cfe/trunk/test/OpenMP/target_vla_messages.cpp
===
--- cfe/trunk/test/OpenMP/target_vla_messages.cpp
+++ cfe/trunk/test/OpenMP/target_vla_messages.cpp
@@ -0,0 +1,201 @@
+// PowerPC supports VLAs.
+// RUN: %clang_cc1 -verify -fopenmp -x c++ -triple powerpc64le-unknown-unknown -fopenmp-targets=powerpc64le-unknown-unknown -emit-llvm-bc %s -o %t-ppc-host-ppc.bc
+// RUN: %clang_cc1 -verify -fopenmp -x c++ -triple powerpc64le-unknown-unknown -fopenmp-targets=powerpc64le-unknown-unknown -emit-llvm %s -fopenmp-is-device -fopenmp-host-ir-file-path %t-ppc-host-ppc.bc -o %t-ppc-device.ll
+
+// Nvidia GPUs don't support VLAs.
+// RUN: %clang_cc1 -verify -fopenmp -x c++ -triple powerpc64le-unknown-unknown -fopenmp-targets=nvptx64-nvidia-cuda -emit-llvm-bc %s -o %t-ppc-host-nvptx.bc
+// RUN: %clang_cc1 -verify -DNO_VLA -fopenmp -x c++ -triple nvptx64-unknown-unknown -fopenmp-targets=nvptx64-nvidia-cuda -emit-llvm %s -fopenmp-is-device -fopenmp-host-ir-file-path %t-ppc-host-nvptx.bc -o %t-nvptx-device.ll
+
+#ifndef NO_VLA
+// expected-no-diagnostics
+#endif
+
+#pragma omp 

r318601 - [OpenMP] Show error if VLAs are not supported

2017-11-18 Thread Jonas Hahnfeld via cfe-commits
Author: hahnfeld
Date: Sat Nov 18 13:00:46 2017
New Revision: 318601

URL: http://llvm.org/viewvc/llvm-project?rev=318601=rev
Log:
[OpenMP] Show error if VLAs are not supported

Some target devices (e.g. Nvidia GPUs) don't support dynamic stack
allocation and hence no VLAs. Print errors with description instead
of failing in the backend or generating code that doesn't work.

This patch handles explicit uses of VLAs (local variable in target
or declare target region) or implicitly generated (private) VLAs
for reductions on VLAs or on array sections with non-constant size.

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

Added:
cfe/trunk/test/OpenMP/target_vla_messages.cpp
Modified:
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
cfe/trunk/include/clang/Basic/TargetInfo.h
cfe/trunk/include/clang/Sema/Sema.h
cfe/trunk/lib/Basic/TargetInfo.cpp
cfe/trunk/lib/Basic/Targets/NVPTX.cpp
cfe/trunk/lib/Basic/Targets/SPIR.h
cfe/trunk/lib/Sema/SemaOpenMP.cpp
cfe/trunk/lib/Sema/SemaType.cpp

Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=318601=318600=318601=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Sat Nov 18 13:00:46 
2017
@@ -141,6 +141,10 @@ def err_vla_decl_has_extern_linkage : Er
   "variable length array declaration cannot have 'extern' linkage">;
 def ext_vla_folded_to_constant : Extension<
   "variable length array folded to constant array as an extension">, 
InGroup;
+def err_vla_unsupported : Error<
+  "variable length arrays are not supported for the current target">;
+def note_vla_unsupported : Note<
+  "variable length arrays are not supported for the current target">;
 
 // C99 variably modified types
 def err_variably_modified_template_arg : Error<
@@ -8985,6 +8989,8 @@ def err_omp_reduction_non_addressable_ex
   "expected addressable reduction item for the task-based directives">;
 def err_omp_reduction_with_nogroup : Error<
   "'reduction' clause cannot be used with 'nogroup' clause">;
+def err_omp_reduction_vla_unsupported : Error<
+  "cannot generate code for reduction on %select{|array section, which 
requires a }0variable length array">;
 } // end of OpenMP category
 
 let CategoryName = "Related Result Type Issue" in {

Modified: cfe/trunk/include/clang/Basic/TargetInfo.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/TargetInfo.h?rev=318601=318600=318601=diff
==
--- cfe/trunk/include/clang/Basic/TargetInfo.h (original)
+++ cfe/trunk/include/clang/Basic/TargetInfo.h Sat Nov 18 13:00:46 2017
@@ -60,6 +60,7 @@ protected:
   // values are specified by the TargetInfo constructor.
   bool BigEndian;
   bool TLSSupported;
+  bool VLASupported;
   bool NoAsmVariants;  // True if {|} are normal characters.
   bool HasFloat128;
   unsigned char PointerWidth, PointerAlign;
@@ -939,6 +940,9 @@ public:
 return MaxTLSAlign;
   }
 
+  /// \brief Whether target supports variable-length arrays.
+  bool isVLASupported() const { return VLASupported; }
+
   /// \brief Whether the target supports SEH __try.
   bool isSEHTrySupported() const {
 return getTriple().isOSWindows() &&

Modified: cfe/trunk/include/clang/Sema/Sema.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Sema.h?rev=318601=318600=318601=diff
==
--- cfe/trunk/include/clang/Sema/Sema.h (original)
+++ cfe/trunk/include/clang/Sema/Sema.h Sat Nov 18 13:00:46 2017
@@ -8653,10 +8653,18 @@ public:
 NamedDeclSetType );
   /// Check declaration inside target region.
   void checkDeclIsAllowedInOpenMPTarget(Expr *E, Decl *D);
-  /// Return true inside OpenMP target region.
+  /// Return true inside OpenMP declare target region.
   bool isInOpenMPDeclareTargetContext() const {
 return IsInOpenMPDeclareTargetContext;
   }
+  /// Return true inside OpenMP target region.
+  bool isInOpenMPTargetExecutionDirective() const;
+  /// Return true if (un)supported features for the current target should be
+  /// diagnosed if OpenMP (offloading) is enabled.
+  bool shouldDiagnoseTargetSupportFromOpenMP() const {
+return !getLangOpts().OpenMPIsDevice || isInOpenMPDeclareTargetContext() ||
+  isInOpenMPTargetExecutionDirective();
+  }
 
   /// Return the number of captured regions created for an OpenMP directive.
   static int getOpenMPCaptureLevels(OpenMPDirectiveKind Kind);

Modified: cfe/trunk/lib/Basic/TargetInfo.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/TargetInfo.cpp?rev=318601=318600=318601=diff

[PATCH] D40210: [libc++] Shrink varient's index type when possible

2017-11-18 Thread Eric Fiselier via Phabricator via cfe-commits
EricWF created this revision.

Currently `std::variant` always uses an unsigned int to store the variant 
index. However this isn't nessesary and causes `std::variant` to be larger than 
it needs to be in most cases.

This patch changes the index type to be `unsigned char` when possible, and 
`unsigned short` or `unsigned int` otherwise, depending on the size (Although 
it's questionable if it's even possible to create a variant with 65535 elements.

Unfortunately this change is an ABI break, and as such is only enabled in ABI 
v2.


https://reviews.llvm.org/D40210

Files:
  include/__config
  include/variant
  test/libcxx/utilities/variant/variant.variant/variant_size.pass.cpp

Index: test/libcxx/utilities/variant/variant.variant/variant_size.pass.cpp
===
--- /dev/null
+++ test/libcxx/utilities/variant/variant.variant/variant_size.pass.cpp
@@ -0,0 +1,69 @@
+// -*- C++ -*-
+//===--===//
+//
+// 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  class variant;
+
+#include 
+#include 
+#include 
+#include 
+#include 
+
+template 
+struct make_variant_imp;
+
+template 
+struct make_variant_imp> {
+  using type = std::variant;
+};
+
+template 
+using make_variant_t = typename make_variant_imp::type;
+
+constexpr bool ExpectEqual =
+#ifdef _LIBCPP_ABI_VARIANT_INDEX_TYPE_OPTIMIZATION
+  false;
+#else
+  true;
+#endif
+
+template 
+void test_index_type() {
+  using Lim = std::numeric_limits;
+  using T1 = make_variant_t;
+  using T2 = make_variant_t;
+  static_assert((sizeof(T1) == sizeof(T2)) == ExpectEqual, "");
+}
+
+template 
+void test_index_internals() {
+  using Lim = std::numeric_limits;
+  static_assert(std::__choose_index_type(Lim::max() -1) !=
+std::__choose_index_type(Lim::max()), "");
+  static_assert(std::is_same_v<
+  std::__variant_index_t,
+  std::__variant_index_t
+> == ExpectEqual, "");
+  using IndexT = std::__variant_index_t;
+  using IndexLim = std::numeric_limits;
+  static_assert(std::__variant_npos == IndexLim::max(), "");
+}
+
+int main() {
+  test_index_type();
+  // This won't compile due to template depth issues.
+  //test_index_type();
+  test_index_internals();
+  test_index_internals();
+}
Index: include/variant
===
--- include/variant
+++ include/variant
@@ -283,7 +283,28 @@
 };
 
 constexpr size_t variant_npos = static_cast(-1);
-constexpr unsigned int __variant_npos = static_cast(-1);
+
+constexpr int __choose_index_type(unsigned int __num_elem) {
+  if (__num_elem < std::numeric_limits::max())
+return 0;
+  if (__num_elem < std::numeric_limits::max())
+return 1;
+  return 2;
+}
+
+template 
+using __variant_index_t =
+#ifndef _LIBCPP_ABI_VARIANT_INDEX_TYPE_OPTIMIZATION
+  unsigned int;
+#else
+  std::tuple_element_t<
+  __choose_index_type(_NumElem),
+  std::tuple
+  >;
+#endif
+
+template 
+constexpr _IntType __variant_npos = static_cast<_IntType>(-1);
 
 namespace __find_detail {
 
@@ -647,9 +668,11 @@
 template <_Trait _DestructibleTrait, class... _Types>
 class _LIBCPP_TEMPLATE_VIS __base {
 public:
+  using __index_t = __variant_index_t;
+
   inline _LIBCPP_INLINE_VISIBILITY
   explicit constexpr __base(__valueless_t tag) noexcept
-  : __data(tag), __index(__variant_npos) {}
+  : __data(tag), __index(__variant_npos<__index_t>) {}
 
   template 
   inline _LIBCPP_INLINE_VISIBILITY
@@ -665,7 +688,7 @@
 
   inline _LIBCPP_INLINE_VISIBILITY
   constexpr size_t index() const noexcept {
-return __index == __variant_npos ? variant_npos : __index;
+return __index == __variant_npos<__index_t> ? variant_npos : __index;
   }
 
 protected:
@@ -685,7 +708,7 @@
   static constexpr size_t __size() { return sizeof...(_Types); }
 
   __union<_DestructibleTrait, 0, _Types...> __data;
-  unsigned int __index;
+  __index_t __index;
 
   friend struct __access::__base;
   friend struct __visitation::__base;
@@ -696,10 +719,11 @@
 
 #define _LIBCPP_VARIANT_DESTRUCTOR(destructible_trait, destructor, destroy)\
   template\
-  class _LIBCPP_TEMPLATE_VIS __destructor<__traits<_Types...>,\
+  class _LIBCPP_TEMPLATE_VIS __destructor<__traits<_Types...>, \
destructible_trait> \
   : public __base {  

[PATCH] D40144: Implement `std::launder`

2017-11-18 Thread Eric Fiselier via Phabricator via cfe-commits
EricWF added a comment.

I think we may want a `__launder` function that we can use internally in all 
dialects.




Comment at: include/__config:458
+#if __has_builtin(__builtin_launder)
+#define_LIBCPP_COMPILER_HAS_BUILTIN_LAUNDER
+#endif

These macros should take the negative `_LIBCPP_HAS_NO_BUILTIN_LAUNDER` form to 
be consistent.



Comment at: include/new:260
+{
+static_assert (!is_function<_Tp>::value, "Can't launder functions" );
+static_assert (!is_same::type>::value, 
"Can't launder cv-void" );

Typically diagnostics don't start with capitals.

Small nit on the use of a contraction too.



Comment at: include/new:261
+static_assert (!is_function<_Tp>::value, "Can't launder functions" );
+static_assert (!is_same::type>::value, 
"Can't launder cv-void" );
+#ifdef _LIBCPP_COMPILER_HAS_BUILTIN_LAUNDER

Since this is C++17 only, we can use the `trait_t` and `trait_v` versions to be 
less verbose. 


https://reviews.llvm.org/D40144



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


[PATCH] D39937: [Sema] Improve diagnostics for const- and ref-qualified member functions

2017-11-18 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri added inline comments.



Comment at: test/CXX/over/over.match/over.match.funcs/p4-0x.cpp:22-24
+  void lvalue() &; // expected-note 2 {{'lvalue' declared here}}
+  void const_lvalue() const&;
+  void rvalue() &&; // expected-note {{'rvalue' declared here}}

aaron.ballman wrote:
> jtbandes wrote:
> > aaron.ballman wrote:
> > > Can you add examples that cover the other diagnostic wordings as well 
> > > (volatile, restrict, combinations, etc)?
> > I've been working on this, but I actually can't trigger the `restrict` 
> > variants. Do you know whether this is something that's expected to work? 
> > The implicit object param doesn't seem to retain its restrict-ness (full 
> > disclosure, I have almost no prior experience with `restrict`...):
> > 
> > ```
> >   void c() const;
> >   void v() volatile;
> >   void r() __restrict__;
> >   void cr() const __restrict__;
> >   void cv() const volatile;
> >   void vr() volatile __restrict__;
> >   void cvr() const volatile __restrict__;
> > ```
> > ```
> > void test_diagnostics(const volatile X0 &__restrict__ cvr) {
> >   cvr.g(); // expected-error {{not marked const, volatile, or restrict}}  
> > -- actually produces "not marked const or volatile"
> >   cvr.c(); // expected-error {{not marked volatile or restrict}}  -- 
> > actually produces "not marked volatile"
> >   cvr.v(); // expected-error {{not marked const or restrict}}  -- actually 
> > produces "not marked const"
> >   cvr.r(); // expected-error {{not marked const or volatile}}
> >   cvr.cr(); // expected-error {{not marked volatile}}
> >   cvr.cv(); // expected-error {{not marked restrict}}  -- actually produces 
> > no error
> >   cvr.vr(); // expected-error {{not marked const}}
> >   cvr.cvr();
> > }
> > ```
> Given that `restrict` is a Cism, it's entirely possible that it's not really 
> supported as a member function qualifier. In that case, one more test for 
> `const volatile` should be sufficient.
Note that you might want to test it regardless, to not miss if it starts to 
warn for some reason.


https://reviews.llvm.org/D39937



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


Re: r318556 - Loosen -Wempty-body warning

2017-11-18 Thread Hans Wennborg via cfe-commits
We're still seeing some in macro-related code. From Chromium:

../../third_party/ffmpeg/libavcodec/bitstream.c(169,5):  error: if
statement has empty body [-Werror,-Wempty-body]
ff_dlog(NULL, "new table index=%d size=%d\n", table_index, table_size);
^
../../third_party/ffmpeg\libavutil/internal.h(276,80):  note: expanded
from macro 'ff_dlog'
#   define ff_dlog(ctx, ...) do { if (0) av_log(ctx, AV_LOG_DEBUG,
__VA_ARGS__); } while (0)
   ^
../../third_party/ffmpeg/libavcodec/bitstream.c(169,5):  note: put the
semicolon on a separate line to silence this warning

(See https://build.chromium.org/p/chromium.clang/builders/ToTWin/builds/420)

On Fri, Nov 17, 2017 at 1:33 PM, Reid Kleckner via cfe-commits
 wrote:
> Author: rnk
> Date: Fri Nov 17 13:33:28 2017
> New Revision: 318556
>
> URL: http://llvm.org/viewvc/llvm-project?rev=318556=rev
> Log:
> Loosen -Wempty-body warning
>
> Do not show it when `if` or `else` come from macros.
> E.g.,
>
> #define USED(A) if (A); else
> #define SOME_IF(A) if (A)
>
> void test() {
>   // No warnings are shown in those cases now.
>   USED(0);
>   SOME_IF(0);
> }
>
> Patch by Ilya Biryukov!
>
> Differential Revision: https://reviews.llvm.org/D40185
>
> Modified:
> cfe/trunk/include/clang/Sema/Sema.h
> cfe/trunk/lib/Parse/ParseStmt.cpp
> cfe/trunk/lib/Sema/SemaChecking.cpp
> cfe/trunk/lib/Sema/SemaStmt.cpp
> cfe/trunk/test/SemaCXX/warn-empty-body.cpp
>
> Modified: cfe/trunk/include/clang/Sema/Sema.h
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Sema.h?rev=318556=318555=318556=diff
> ==
> --- cfe/trunk/include/clang/Sema/Sema.h (original)
> +++ cfe/trunk/include/clang/Sema/Sema.h Fri Nov 17 13:33:28 2017
> @@ -9690,6 +9690,7 @@ public:
>class ConditionResult {
>  Decl *ConditionVar;
>  FullExprArg Condition;
> +SourceLocation RParenLoc;
>  bool Invalid;
>  bool HasKnownValue;
>  bool KnownValue;
> @@ -9713,6 +9714,9 @@ public:
>return std::make_pair(cast_or_null(ConditionVar),
>  Condition.get());
>  }
> +
> +void setRParenLoc(SourceLocation Loc) { RParenLoc = Loc; }
> +
>  llvm::Optional getKnownValue() const {
>if (!HasKnownValue)
>  return None;
>
> Modified: cfe/trunk/lib/Parse/ParseStmt.cpp
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseStmt.cpp?rev=318556=318555=318556=diff
> ==
> --- cfe/trunk/lib/Parse/ParseStmt.cpp (original)
> +++ cfe/trunk/lib/Parse/ParseStmt.cpp Fri Nov 17 13:33:28 2017
> @@ -1101,6 +1101,7 @@ bool Parser::ParseParenExprOrCondition(S
>
>// Otherwise the condition is valid or the rparen is present.
>T.consumeClose();
> +  Cond.setRParenLoc(T.getCloseLocation());
>
>// Check for extraneous ')'s to catch things like "if (foo())) {".  We know
>// that all callers are looking for a statement after the condition, so ")"
>
> Modified: cfe/trunk/lib/Sema/SemaChecking.cpp
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaChecking.cpp?rev=318556=318555=318556=diff
> ==
> --- cfe/trunk/lib/Sema/SemaChecking.cpp (original)
> +++ cfe/trunk/lib/Sema/SemaChecking.cpp Fri Nov 17 13:33:28 2017
> @@ -11821,7 +11821,7 @@ static bool ShouldDiagnoseEmptyStmtBody(
>
>// Get line numbers of statement and body.
>bool StmtLineInvalid;
> -  unsigned StmtLine = SourceMgr.getPresumedLineNumber(StmtLoc,
> +  unsigned StmtLine = SourceMgr.getSpellingLineNumber(StmtLoc,
>);
>if (StmtLineInvalid)
>  return false;
>
> Modified: cfe/trunk/lib/Sema/SemaStmt.cpp
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaStmt.cpp?rev=318556=318555=318556=diff
> ==
> --- cfe/trunk/lib/Sema/SemaStmt.cpp (original)
> +++ cfe/trunk/lib/Sema/SemaStmt.cpp Fri Nov 17 13:33:28 2017
> @@ -530,8 +530,7 @@ Sema::ActOnIfStmt(SourceLocation IfLoc,
>if (elseStmt)
>  DiagnoseEmptyStmtBody(ElseLoc, elseStmt, diag::warn_empty_else_body);
>else
> -DiagnoseEmptyStmtBody(CondExpr->getLocEnd(), thenStmt,
> -  diag::warn_empty_if_body);
> +DiagnoseEmptyStmtBody(Cond.RParenLoc, thenStmt, 
> diag::warn_empty_if_body);
>
>return BuildIfStmt(IfLoc, IsConstexpr, InitStmt, Cond, thenStmt, ElseLoc,
>   elseStmt);
>
> Modified: cfe/trunk/test/SemaCXX/warn-empty-body.cpp
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/warn-empty-body.cpp?rev=318556=318555=318556=diff
> 

[PATCH] D37808: [clang-tidy] Add new hicpp-multiway-paths-covered check for missing branches

2017-11-18 Thread Jonas Toth via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL318600: [clang-tidy] Add new hicpp-multiway-paths-covered 
check for missing branches (authored by JonasToth).

Repository:
  rL LLVM

https://reviews.llvm.org/D37808

Files:
  clang-tools-extra/trunk/clang-tidy/hicpp/CMakeLists.txt
  clang-tools-extra/trunk/clang-tidy/hicpp/HICPPTidyModule.cpp
  clang-tools-extra/trunk/clang-tidy/hicpp/MultiwayPathsCoveredCheck.cpp
  clang-tools-extra/trunk/clang-tidy/hicpp/MultiwayPathsCoveredCheck.h
  clang-tools-extra/trunk/docs/ReleaseNotes.rst
  
clang-tools-extra/trunk/docs/clang-tidy/checks/hicpp-multiway-paths-covered.rst
  clang-tools-extra/trunk/docs/clang-tidy/checks/list.rst
  clang-tools-extra/trunk/test/clang-tidy/hicpp-multiway-paths-covered-else.cpp
  clang-tools-extra/trunk/test/clang-tidy/hicpp-multiway-paths-covered.cpp

Index: clang-tools-extra/trunk/clang-tidy/hicpp/MultiwayPathsCoveredCheck.cpp
===
--- clang-tools-extra/trunk/clang-tidy/hicpp/MultiwayPathsCoveredCheck.cpp
+++ clang-tools-extra/trunk/clang-tidy/hicpp/MultiwayPathsCoveredCheck.cpp
@@ -0,0 +1,179 @@
+//===--- MultiwayPathsCoveredCheck.cpp - clang-tidy===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#include "MultiwayPathsCoveredCheck.h"
+#include "clang/AST/ASTContext.h"
+
+#include 
+
+using namespace clang::ast_matchers;
+
+namespace clang {
+namespace tidy {
+namespace hicpp {
+
+void MultiwayPathsCoveredCheck::storeOptions(
+ClangTidyOptions::OptionMap ) {
+  Options.store(Opts, "WarnOnMissingElse", WarnOnMissingElse);
+}
+
+void MultiwayPathsCoveredCheck::registerMatchers(MatchFinder *Finder) {
+  Finder->addMatcher(
+  stmt(allOf(
+  anyOf(switchStmt(forEachSwitchCase(defaultStmt()))
+.bind("switch-default"),
+switchStmt(unless(hasDescendant(switchCase(
+.bind("degenerate-switch"),
+// This matcher must be the last one of the three
+// 'switchStmt' options.
+// Otherwise the cases 'switch-default' and
+// 'degenerate-switch' are not found correctly.
+switchStmt(forEachSwitchCase(unless(defaultStmt(
+.bind("switch-no-default")),
+  switchStmt(hasCondition(allOf(
+  // Match on switch statements that have either a bit-field or an
+  // integer condition. The ordering in 'anyOf()' is important
+  // because the last condition is the most general.
+  anyOf(ignoringImpCasts(memberExpr(hasDeclaration(
+fieldDecl(isBitField()).bind("bitfield",
+hasDescendant(declRefExpr().bind("non-enum-condition"))),
+  // 'unless()' must be the last match here and must be bound,
+  // otherwise the matcher does not work correctly.
+  unless(hasDescendant(declRefExpr(hasType(enumType()))
+   .bind("enum-condition",
+  this);
+
+  // This option is noisy, therefore matching is configurable.
+  if (WarnOnMissingElse) {
+Finder->addMatcher(
+ifStmt(allOf(hasParent(ifStmt()), unless(hasElse(anything()
+.bind("else-if"),
+this);
+  }
+}
+
+static unsigned countCaseLabels(const SwitchStmt *Switch) {
+  unsigned CaseCount = 0;
+
+  const SwitchCase *CurrentCase = Switch->getSwitchCaseList();
+  while (CurrentCase) {
+++CaseCount;
+CurrentCase = CurrentCase->getNextSwitchCase();
+  }
+
+  return CaseCount;
+}
+/// This function calculate 2 ** Bits and returns
+/// numeric_limits::max() if an overflow occured.
+static std::size_t twoPow(std::size_t Bits) {
+  return Bits >= std::numeric_limits::digits
+ ? std::numeric_limits::max()
+ : static_cast(1) << Bits;
+}
+/// Get the number of possible values that can be switched on for the type T.
+///
+/// \return - 0 if bitcount could not be determined
+/// - numeric_limits::max() when overflow appeared due to
+///   more then 64 bits type size.
+static std::size_t getNumberOfPossibleValues(QualType T,
+ const ASTContext ) {
+  // `isBooleanType` must come first because `bool` is an integral type as well
+  // and would not return 2 as result.
+  if (T->isBooleanType())
+return 2;
+  else if (T->isIntegralType(Context))
+return twoPow(Context.getTypeSize(T));
+  else
+return 1;
+}
+
+void MultiwayPathsCoveredCheck::check(const MatchFinder::MatchResult ) {
+  if (const auto *ElseIfWithoutElse =
+  Result.Nodes.getNodeAs("else-if")) {
+

[clang-tools-extra] r318600 - [clang-tidy] Add new hicpp-multiway-paths-covered check for missing branches

2017-11-18 Thread Jonas Toth via cfe-commits
Author: jonastoth
Date: Sat Nov 18 11:48:33 2017
New Revision: 318600

URL: http://llvm.org/viewvc/llvm-project?rev=318600=rev
Log:
[clang-tidy] Add new hicpp-multiway-paths-covered check for missing branches

Summary:
This check searches for missing `else` branches in `if-else if`-chains and
missing `default` labels in `switch` statements, that use integers as condition.

It is very similar to -Wswitch, but concentrates on integers only, since enums 
are
already covered.

The option to warn for missing `else` branches is deactivated by default, since 
it is
very noise on larger code bases.

Running it on LLVM:
{F5354858} for default configuration
{F5354866} just for llvm/lib/Analysis/ScalarEvolution.cpp, the else-path 
checker is very noisy!

Reviewers: alexfh, aaron.ballman, hokein

Reviewed By: aaron.ballman

Subscribers: lebedev.ri, Eugene.Zelenko, cfe-commits, mgorny, JDevlieghere, 
xazax.hun

Tags: #clang-tools-extra

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


Added:
clang-tools-extra/trunk/clang-tidy/hicpp/MultiwayPathsCoveredCheck.cpp
clang-tools-extra/trunk/clang-tidy/hicpp/MultiwayPathsCoveredCheck.h

clang-tools-extra/trunk/docs/clang-tidy/checks/hicpp-multiway-paths-covered.rst

clang-tools-extra/trunk/test/clang-tidy/hicpp-multiway-paths-covered-else.cpp
clang-tools-extra/trunk/test/clang-tidy/hicpp-multiway-paths-covered.cpp
Modified:
clang-tools-extra/trunk/clang-tidy/hicpp/CMakeLists.txt
clang-tools-extra/trunk/clang-tidy/hicpp/HICPPTidyModule.cpp
clang-tools-extra/trunk/docs/ReleaseNotes.rst
clang-tools-extra/trunk/docs/clang-tidy/checks/list.rst

Modified: clang-tools-extra/trunk/clang-tidy/hicpp/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/hicpp/CMakeLists.txt?rev=318600=318599=318600=diff
==
--- clang-tools-extra/trunk/clang-tidy/hicpp/CMakeLists.txt (original)
+++ clang-tools-extra/trunk/clang-tidy/hicpp/CMakeLists.txt Sat Nov 18 11:48:33 
2017
@@ -2,6 +2,7 @@ set(LLVM_LINK_COMPONENTS support)
 
 add_clang_library(clangTidyHICPPModule
   ExceptionBaseclassCheck.cpp
+  MultiwayPathsCoveredCheck.cpp
   NoAssemblerCheck.cpp
   HICPPTidyModule.cpp
   SignedBitwiseCheck.cpp

Modified: clang-tools-extra/trunk/clang-tidy/hicpp/HICPPTidyModule.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/hicpp/HICPPTidyModule.cpp?rev=318600=318599=318600=diff
==
--- clang-tools-extra/trunk/clang-tidy/hicpp/HICPPTidyModule.cpp (original)
+++ clang-tools-extra/trunk/clang-tidy/hicpp/HICPPTidyModule.cpp Sat Nov 18 
11:48:33 2017
@@ -35,6 +35,7 @@
 #include "../readability/FunctionSizeCheck.h"
 #include "../readability/IdentifierNamingCheck.h"
 #include "ExceptionBaseclassCheck.h"
+#include "MultiwayPathsCoveredCheck.h"
 #include "NoAssemblerCheck.h"
 #include "SignedBitwiseCheck.h"
 
@@ -53,6 +54,8 @@ public:
 "hicpp-exception-baseclass");
 CheckFactories.registerCheck(
 "hicpp-signed-bitwise");
+CheckFactories.registerCheck(
+"hicpp-multiway-paths-covered");
 CheckFactories.registerCheck(
 "hicpp-explicit-conversions");
 CheckFactories.registerCheck(

Added: clang-tools-extra/trunk/clang-tidy/hicpp/MultiwayPathsCoveredCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/hicpp/MultiwayPathsCoveredCheck.cpp?rev=318600=auto
==
--- clang-tools-extra/trunk/clang-tidy/hicpp/MultiwayPathsCoveredCheck.cpp 
(added)
+++ clang-tools-extra/trunk/clang-tidy/hicpp/MultiwayPathsCoveredCheck.cpp Sat 
Nov 18 11:48:33 2017
@@ -0,0 +1,179 @@
+//===--- MultiwayPathsCoveredCheck.cpp - 
clang-tidy===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#include "MultiwayPathsCoveredCheck.h"
+#include "clang/AST/ASTContext.h"
+
+#include 
+
+using namespace clang::ast_matchers;
+
+namespace clang {
+namespace tidy {
+namespace hicpp {
+
+void MultiwayPathsCoveredCheck::storeOptions(
+ClangTidyOptions::OptionMap ) {
+  Options.store(Opts, "WarnOnMissingElse", WarnOnMissingElse);
+}
+
+void MultiwayPathsCoveredCheck::registerMatchers(MatchFinder *Finder) {
+  Finder->addMatcher(
+  stmt(allOf(
+  anyOf(switchStmt(forEachSwitchCase(defaultStmt()))
+.bind("switch-default"),
+switchStmt(unless(hasDescendant(switchCase(
+.bind("degenerate-switch"),
+// This matcher must be the last one of the three
+// 'switchStmt' options.
+// Otherwise the 

[PATCH] D39937: [Sema] Improve diagnostics for const- and ref-qualified member functions

2017-11-18 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: test/CXX/over/over.match/over.match.funcs/p4-0x.cpp:22-24
+  void lvalue() &; // expected-note 2 {{'lvalue' declared here}}
+  void const_lvalue() const&;
+  void rvalue() &&; // expected-note {{'rvalue' declared here}}

jtbandes wrote:
> aaron.ballman wrote:
> > Can you add examples that cover the other diagnostic wordings as well 
> > (volatile, restrict, combinations, etc)?
> I've been working on this, but I actually can't trigger the `restrict` 
> variants. Do you know whether this is something that's expected to work? The 
> implicit object param doesn't seem to retain its restrict-ness (full 
> disclosure, I have almost no prior experience with `restrict`...):
> 
> ```
>   void c() const;
>   void v() volatile;
>   void r() __restrict__;
>   void cr() const __restrict__;
>   void cv() const volatile;
>   void vr() volatile __restrict__;
>   void cvr() const volatile __restrict__;
> ```
> ```
> void test_diagnostics(const volatile X0 &__restrict__ cvr) {
>   cvr.g(); // expected-error {{not marked const, volatile, or restrict}}  -- 
> actually produces "not marked const or volatile"
>   cvr.c(); // expected-error {{not marked volatile or restrict}}  -- actually 
> produces "not marked volatile"
>   cvr.v(); // expected-error {{not marked const or restrict}}  -- actually 
> produces "not marked const"
>   cvr.r(); // expected-error {{not marked const or volatile}}
>   cvr.cr(); // expected-error {{not marked volatile}}
>   cvr.cv(); // expected-error {{not marked restrict}}  -- actually produces 
> no error
>   cvr.vr(); // expected-error {{not marked const}}
>   cvr.cvr();
> }
> ```
Given that `restrict` is a Cism, it's entirely possible that it's not really 
supported as a member function qualifier. In that case, one more test for 
`const volatile` should be sufficient.


https://reviews.llvm.org/D39937



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


[PATCH] D37808: [clang-tidy] Add new hicpp-multiway-paths-covered check for missing branches

2017-11-18 Thread Jonas Toth via Phabricator via cfe-commits
JonasToth added a comment.

finalize


https://reviews.llvm.org/D37808



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


[PATCH] D37808: [clang-tidy] Add new hicpp-multiway-paths-covered check for missing branches

2017-11-18 Thread Jonas Toth via Phabricator via cfe-commits
JonasToth updated this revision to Diff 123468.
JonasToth marked 3 inline comments as done.
JonasToth added a comment.

- fix nits


https://reviews.llvm.org/D37808

Files:
  clang-tidy/hicpp/CMakeLists.txt
  clang-tidy/hicpp/HICPPTidyModule.cpp
  clang-tidy/hicpp/MultiwayPathsCoveredCheck.cpp
  clang-tidy/hicpp/MultiwayPathsCoveredCheck.h
  docs/ReleaseNotes.rst
  docs/clang-tidy/checks/hicpp-multiway-paths-covered.rst
  docs/clang-tidy/checks/list.rst
  test/clang-tidy/hicpp-multiway-paths-covered-else.cpp
  test/clang-tidy/hicpp-multiway-paths-covered.cpp

Index: test/clang-tidy/hicpp-multiway-paths-covered.cpp
===
--- /dev/null
+++ test/clang-tidy/hicpp-multiway-paths-covered.cpp
@@ -0,0 +1,467 @@
+// RUN: %check_clang_tidy %s hicpp-multiway-paths-covered %t
+
+enum OS { Mac,
+  Windows,
+  Linux };
+
+struct Bitfields {
+  unsigned UInt : 3;
+  int SInt : 1;
+};
+
+int return_integer() { return 42; }
+
+void bad_switch(int i) {
+  switch (i) {
+// CHECK-MESSAGES: [[@LINE-1]]:3: warning: switch with only one case; use an if statement
+  case 0:
+break;
+  }
+  // No default in this switch
+  switch (i) {
+  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: potential uncovered code path; add a default label
+  case 0:
+break;
+  case 1:
+break;
+  case 2:
+break;
+  }
+
+  // degenerate, maybe even warning
+  switch (i) {
+// CHECK-MESSAGES: [[@LINE-1]]:3: warning: degenerated switch without labels
+  }
+
+  switch (int j = return_integer()) {
+  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: potential uncovered code path; add a default label
+  case 0:
+  case 1:
+  case 2:
+break;
+  }
+
+  // Degenerated, only default case.
+  switch (i) {
+// CHECK-MESSAGES: [[@LINE-1]]:3: warning: degenerated switch with default label only
+  default:
+break;
+  }
+
+  // Degenerated, only one case label and default case -> Better as if-stmt.
+  switch (i) {
+// CHECK-MESSAGES: [[@LINE-1]]:3: warning: switch could be better written as an if/else statement
+  case 0:
+break;
+  default:
+break;
+  }
+
+  unsigned long long BigNumber = 0;
+  switch (BigNumber) {
+  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: potential uncovered code path; add a default label
+  case 0:
+  case 1:
+break;
+  }
+
+  const int  = i;
+  switch (IntRef) {
+  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: potential uncovered code path; add a default label
+  case 0:
+  case 1:
+break;
+  }
+
+  char C = 'A';
+  switch (C) {
+  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: potential uncovered code path; add a default label
+  case 'A':
+break;
+  case 'B':
+break;
+  }
+
+  Bitfields Bf;
+  // UInt has 3 bits size.
+  switch (Bf.UInt) {
+// CHECK-MESSAGES: [[@LINE-1]]:3: warning: potential uncovered code path; add a default label
+  case 0:
+  case 1:
+break;
+  }
+  // All paths explicitly covered.
+  switch (Bf.UInt) {
+  case 0:
+  case 1:
+  case 2:
+  case 3:
+  case 4:
+  case 5:
+  case 6:
+  case 7:
+break;
+  }
+  // SInt has 1 bit size, so this is somewhat degenerated.
+  switch (Bf.SInt) {
+// CHECK-MESSAGES: [[@LINE-1]]:3: warning: switch with only one case; use an if statement
+  case 0:
+break;
+  }
+  // All paths explicitly covered.
+  switch (Bf.SInt) {
+  case 0:
+  case 1:
+break;
+  }
+
+  bool Flag = false;
+  switch (Flag) {
+// CHECK-MESSAGES:[[@LINE-1]]:3: warning: switch with only one case; use an if statement
+  case true:
+break;
+  }
+
+  switch (Flag) {
+// CHECK-MESSAGES: [[@LINE-1]]:3: warning: degenerated switch with default label only
+  default:
+break;
+  }
+
+  // This `switch` will create a frontend warning from '-Wswitch-bool' but is
+  // ok for this check.
+  switch (Flag) {
+  case true:
+break;
+  case false:
+break;
+  }
+}
+
+void unproblematic_switch(unsigned char c) {
+  switch (c) {
+  case 0:
+  case 1:
+  case 2:
+  case 3:
+  case 4:
+  case 5:
+  case 6:
+  case 7:
+  case 8:
+  case 9:
+  case 10:
+  case 11:
+  case 12:
+  case 13:
+  case 14:
+  case 15:
+  case 16:
+  case 17:
+  case 18:
+  case 19:
+  case 20:
+  case 21:
+  case 22:
+  case 23:
+  case 24:
+  case 25:
+  case 26:
+  case 27:
+  case 28:
+  case 29:
+  case 30:
+  case 31:
+  case 32:
+  case 33:
+  case 34:
+  case 35:
+  case 36:
+  case 37:
+  case 38:
+  case 39:
+  case 40:
+  case 41:
+  case 42:
+  case 43:
+  case 44:
+  case 45:
+  case 46:
+  case 47:
+  case 48:
+  case 49:
+  case 50:
+  case 51:
+  case 52:
+  case 53:
+  case 54:
+  case 55:
+  case 56:
+  case 57:
+  case 58:
+  case 59:
+  case 60:
+  case 61:
+  case 62:
+  case 63:
+  case 64:
+  case 65:
+  case 66:
+  case 67:
+  case 68:
+  case 69:
+  case 70:
+  case 71:
+  case 72:
+  case 73:
+  case 74:
+  case 75:
+  case 76:
+  case 77:
+  case 78:
+  case 79:
+  case 80:
+  case 81:
+  case 82:
+  case 83:
+  case 84:
+  case 85:
+  case 86:
+  case 87:
+  case 88:
+  

[PATCH] D37808: [clang-tidy] Add new hicpp-multiway-paths-covered check for missing branches

2017-11-18 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.

Aside from some minor commenting nits, LGTM




Comment at: clang-tidy/hicpp/MultiwayPathsCoveredCheck.cpp:41
+  switchStmt(hasCondition(allOf(
+  // Match on switch statements that have either bitfield or 
integer
+  // condition.

aaron.ballman wrote:
> either bitfield or integer condition -> either a bit-field or an integer 
> condition
bitfield -> bit-field



Comment at: clang-tidy/hicpp/MultiwayPathsCoveredCheck.cpp:91-92
+  // Context.getTypeSize(T) returns the number of bits T uses.
+  // Calculates the number of discrete values that are representable by this
+  // type.
+  return T->isIntegralType(Context) ? twoPow(Context.getTypeSize(T))

JonasToth wrote:
> aaron.ballman wrote:
> > I don't think this comment adds value.
> i dropped all of it. The function doc should be clear enough, is it?
Yes, I think so.



Comment at: clang-tidy/hicpp/MultiwayPathsCoveredCheck.cpp:168
+  return twoPow(BitfieldDecl->getBitWidthValue(*Result.Context));
+llvm_unreachable("either bitfield or non-enum must be condition");
+  }();

bitfield -> bit-field


https://reviews.llvm.org/D37808



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


[PATCH] D39665: Support __has_c_attribute

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

Ping


https://reviews.llvm.org/D39665



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


[PATCH] D39611: [CodeGen] change const-ness of complex calls

2017-11-18 Thread Sanjay Patel via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL318598: [CodeGen] change const-ness of complex calls 
(authored by spatel).

Changed prior to commit:
  https://reviews.llvm.org/D39611?vs=122474=123467#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D39611

Files:
  cfe/trunk/include/clang/Basic/Builtins.def
  cfe/trunk/test/CodeGen/complex-builtins.c
  cfe/trunk/test/CodeGen/complex-libcalls.c
  cfe/trunk/test/CodeGen/libcall-declarations.c

Index: cfe/trunk/include/clang/Basic/Builtins.def
===
--- cfe/trunk/include/clang/Basic/Builtins.def
+++ cfe/trunk/include/clang/Basic/Builtins.def
@@ -293,72 +293,72 @@
 BUILTIN(__builtin_truncl, "LdLd", "Fnc")
 
 // C99 complex builtins
-BUILTIN(__builtin_cabs, "dXd", "Fnc")
-BUILTIN(__builtin_cabsf, "fXf", "Fnc")
-BUILTIN(__builtin_cabsl, "LdXLd", "Fnc")
-BUILTIN(__builtin_cacos, "XdXd", "Fnc")
-BUILTIN(__builtin_cacosf, "XfXf", "Fnc")
-BUILTIN(__builtin_cacosh, "XdXd", "Fnc")
-BUILTIN(__builtin_cacoshf, "XfXf", "Fnc")
-BUILTIN(__builtin_cacoshl, "XLdXLd", "Fnc")
-BUILTIN(__builtin_cacosl, "XLdXLd", "Fnc")
-BUILTIN(__builtin_carg, "dXd", "Fnc")
-BUILTIN(__builtin_cargf, "fXf", "Fnc")
-BUILTIN(__builtin_cargl, "LdXLd", "Fnc")
-BUILTIN(__builtin_casin, "XdXd", "Fnc")
-BUILTIN(__builtin_casinf, "XfXf", "Fnc")
-BUILTIN(__builtin_casinh, "XdXd", "Fnc")
-BUILTIN(__builtin_casinhf, "XfXf", "Fnc")
-BUILTIN(__builtin_casinhl, "XLdXLd", "Fnc")
-BUILTIN(__builtin_casinl, "XLdXLd", "Fnc")
-BUILTIN(__builtin_catan, "XdXd", "Fnc")
-BUILTIN(__builtin_catanf, "XfXf", "Fnc")
-BUILTIN(__builtin_catanh, "XdXd", "Fnc")
-BUILTIN(__builtin_catanhf, "XfXf", "Fnc")
-BUILTIN(__builtin_catanhl, "XLdXLd", "Fnc")
-BUILTIN(__builtin_catanl, "XLdXLd", "Fnc")
-BUILTIN(__builtin_ccos, "XdXd", "Fnc")
-BUILTIN(__builtin_ccosf, "XfXf", "Fnc")
-BUILTIN(__builtin_ccosl, "XLdXLd", "Fnc")
-BUILTIN(__builtin_ccosh, "XdXd", "Fnc")
-BUILTIN(__builtin_ccoshf, "XfXf", "Fnc")
-BUILTIN(__builtin_ccoshl, "XLdXLd", "Fnc")
-BUILTIN(__builtin_cexp, "XdXd", "Fnc")
-BUILTIN(__builtin_cexpf, "XfXf", "Fnc")
-BUILTIN(__builtin_cexpl, "XLdXLd", "Fnc")
+BUILTIN(__builtin_cabs, "dXd", "Fne")
+BUILTIN(__builtin_cabsf, "fXf", "Fne")
+BUILTIN(__builtin_cabsl, "LdXLd", "Fne")
+BUILTIN(__builtin_cacos, "XdXd", "Fne")
+BUILTIN(__builtin_cacosf, "XfXf", "Fne")
+BUILTIN(__builtin_cacosh, "XdXd", "Fne")
+BUILTIN(__builtin_cacoshf, "XfXf", "Fne")
+BUILTIN(__builtin_cacoshl, "XLdXLd", "Fne")
+BUILTIN(__builtin_cacosl, "XLdXLd", "Fne")
+BUILTIN(__builtin_carg, "dXd", "Fne")
+BUILTIN(__builtin_cargf, "fXf", "Fne")
+BUILTIN(__builtin_cargl, "LdXLd", "Fne")
+BUILTIN(__builtin_casin, "XdXd", "Fne")
+BUILTIN(__builtin_casinf, "XfXf", "Fne")
+BUILTIN(__builtin_casinh, "XdXd", "Fne")
+BUILTIN(__builtin_casinhf, "XfXf", "Fne")
+BUILTIN(__builtin_casinhl, "XLdXLd", "Fne")
+BUILTIN(__builtin_casinl, "XLdXLd", "Fne")
+BUILTIN(__builtin_catan, "XdXd", "Fne")
+BUILTIN(__builtin_catanf, "XfXf", "Fne")
+BUILTIN(__builtin_catanh, "XdXd", "Fne")
+BUILTIN(__builtin_catanhf, "XfXf", "Fne")
+BUILTIN(__builtin_catanhl, "XLdXLd", "Fne")
+BUILTIN(__builtin_catanl, "XLdXLd", "Fne")
+BUILTIN(__builtin_ccos, "XdXd", "Fne")
+BUILTIN(__builtin_ccosf, "XfXf", "Fne")
+BUILTIN(__builtin_ccosl, "XLdXLd", "Fne")
+BUILTIN(__builtin_ccosh, "XdXd", "Fne")
+BUILTIN(__builtin_ccoshf, "XfXf", "Fne")
+BUILTIN(__builtin_ccoshl, "XLdXLd", "Fne")
+BUILTIN(__builtin_cexp, "XdXd", "Fne")
+BUILTIN(__builtin_cexpf, "XfXf", "Fne")
+BUILTIN(__builtin_cexpl, "XLdXLd", "Fne")
 BUILTIN(__builtin_cimag, "dXd", "Fnc")
 BUILTIN(__builtin_cimagf, "fXf", "Fnc")
 BUILTIN(__builtin_cimagl, "LdXLd", "Fnc")
 BUILTIN(__builtin_conj, "XdXd", "Fnc")
 BUILTIN(__builtin_conjf, "XfXf", "Fnc")
 BUILTIN(__builtin_conjl, "XLdXLd", "Fnc")
-BUILTIN(__builtin_clog, "XdXd", "Fnc")
-BUILTIN(__builtin_clogf, "XfXf", "Fnc")
-BUILTIN(__builtin_clogl, "XLdXLd", "Fnc")
+BUILTIN(__builtin_clog, "XdXd", "Fne")
+BUILTIN(__builtin_clogf, "XfXf", "Fne")
+BUILTIN(__builtin_clogl, "XLdXLd", "Fne")
 BUILTIN(__builtin_cproj, "XdXd", "Fnc")
 BUILTIN(__builtin_cprojf, "XfXf", "Fnc")
 BUILTIN(__builtin_cprojl, "XLdXLd", "Fnc")
-BUILTIN(__builtin_cpow, "XdXdXd", "Fnc")
-BUILTIN(__builtin_cpowf, "XfXfXf", "Fnc")
-BUILTIN(__builtin_cpowl, "XLdXLdXLd", "Fnc")
+BUILTIN(__builtin_cpow, "XdXdXd", "Fne")
+BUILTIN(__builtin_cpowf, "XfXfXf", "Fne")
+BUILTIN(__builtin_cpowl, "XLdXLdXLd", "Fne")
 BUILTIN(__builtin_creal, "dXd", "Fnc")
 BUILTIN(__builtin_crealf, "fXf", "Fnc")
 BUILTIN(__builtin_creall, "LdXLd", "Fnc")
-BUILTIN(__builtin_csin, "XdXd", "Fnc")
-BUILTIN(__builtin_csinf, "XfXf", "Fnc")
-BUILTIN(__builtin_csinl, "XLdXLd", "Fnc")
-BUILTIN(__builtin_csinh, "XdXd", "Fnc")
-BUILTIN(__builtin_csinhf, "XfXf", "Fnc")
-BUILTIN(__builtin_csinhl, "XLdXLd", "Fnc")
-BUILTIN(__builtin_csqrt, "XdXd", "Fnc")
-BUILTIN(__builtin_csqrtf, "XfXf", "Fnc")
-BUILTIN(__builtin_csqrtl, "XLdXLd", "Fnc")
-BUILTIN(__builtin_ctan, "XdXd", 

r318598 - [CodeGen] change const-ness of complex calls

2017-11-18 Thread Sanjay Patel via cfe-commits
Author: spatel
Date: Sat Nov 18 11:31:57 2017
New Revision: 318598

URL: http://llvm.org/viewvc/llvm-project?rev=318598=rev
Log:
[CodeGen] change const-ness of complex calls

After clarification about the C standard, POSIX, and implementations:
The C standard allows errno-setting, and it's (unfortunately for optimization) 
even 
more clearly stated in the newer additions to the standards.

We can leave these functions as always constant ('c') because they don't 
actually do any math and therefore won't set errno:
cimag ( http://en.cppreference.com/w/c/numeric/complex/cimag )
creal ( http://en.cppreference.com/w/c/numeric/complex/creal )
cproj ( http://en.cppreference.com/w/c/numeric/complex/cproj )
conj (http://en.cppreference.com/w/c/numeric/complex/conj ) 

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

Modified:
cfe/trunk/include/clang/Basic/Builtins.def
cfe/trunk/test/CodeGen/complex-builtins.c
cfe/trunk/test/CodeGen/complex-libcalls.c
cfe/trunk/test/CodeGen/libcall-declarations.c

Modified: cfe/trunk/include/clang/Basic/Builtins.def
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Builtins.def?rev=318598=318597=318598=diff
==
--- cfe/trunk/include/clang/Basic/Builtins.def (original)
+++ cfe/trunk/include/clang/Basic/Builtins.def Sat Nov 18 11:31:57 2017
@@ -293,72 +293,72 @@ BUILTIN(__builtin_truncf, "ff", "Fnc")
 BUILTIN(__builtin_truncl, "LdLd", "Fnc")
 
 // C99 complex builtins
-BUILTIN(__builtin_cabs, "dXd", "Fnc")
-BUILTIN(__builtin_cabsf, "fXf", "Fnc")
-BUILTIN(__builtin_cabsl, "LdXLd", "Fnc")
-BUILTIN(__builtin_cacos, "XdXd", "Fnc")
-BUILTIN(__builtin_cacosf, "XfXf", "Fnc")
-BUILTIN(__builtin_cacosh, "XdXd", "Fnc")
-BUILTIN(__builtin_cacoshf, "XfXf", "Fnc")
-BUILTIN(__builtin_cacoshl, "XLdXLd", "Fnc")
-BUILTIN(__builtin_cacosl, "XLdXLd", "Fnc")
-BUILTIN(__builtin_carg, "dXd", "Fnc")
-BUILTIN(__builtin_cargf, "fXf", "Fnc")
-BUILTIN(__builtin_cargl, "LdXLd", "Fnc")
-BUILTIN(__builtin_casin, "XdXd", "Fnc")
-BUILTIN(__builtin_casinf, "XfXf", "Fnc")
-BUILTIN(__builtin_casinh, "XdXd", "Fnc")
-BUILTIN(__builtin_casinhf, "XfXf", "Fnc")
-BUILTIN(__builtin_casinhl, "XLdXLd", "Fnc")
-BUILTIN(__builtin_casinl, "XLdXLd", "Fnc")
-BUILTIN(__builtin_catan, "XdXd", "Fnc")
-BUILTIN(__builtin_catanf, "XfXf", "Fnc")
-BUILTIN(__builtin_catanh, "XdXd", "Fnc")
-BUILTIN(__builtin_catanhf, "XfXf", "Fnc")
-BUILTIN(__builtin_catanhl, "XLdXLd", "Fnc")
-BUILTIN(__builtin_catanl, "XLdXLd", "Fnc")
-BUILTIN(__builtin_ccos, "XdXd", "Fnc")
-BUILTIN(__builtin_ccosf, "XfXf", "Fnc")
-BUILTIN(__builtin_ccosl, "XLdXLd", "Fnc")
-BUILTIN(__builtin_ccosh, "XdXd", "Fnc")
-BUILTIN(__builtin_ccoshf, "XfXf", "Fnc")
-BUILTIN(__builtin_ccoshl, "XLdXLd", "Fnc")
-BUILTIN(__builtin_cexp, "XdXd", "Fnc")
-BUILTIN(__builtin_cexpf, "XfXf", "Fnc")
-BUILTIN(__builtin_cexpl, "XLdXLd", "Fnc")
+BUILTIN(__builtin_cabs, "dXd", "Fne")
+BUILTIN(__builtin_cabsf, "fXf", "Fne")
+BUILTIN(__builtin_cabsl, "LdXLd", "Fne")
+BUILTIN(__builtin_cacos, "XdXd", "Fne")
+BUILTIN(__builtin_cacosf, "XfXf", "Fne")
+BUILTIN(__builtin_cacosh, "XdXd", "Fne")
+BUILTIN(__builtin_cacoshf, "XfXf", "Fne")
+BUILTIN(__builtin_cacoshl, "XLdXLd", "Fne")
+BUILTIN(__builtin_cacosl, "XLdXLd", "Fne")
+BUILTIN(__builtin_carg, "dXd", "Fne")
+BUILTIN(__builtin_cargf, "fXf", "Fne")
+BUILTIN(__builtin_cargl, "LdXLd", "Fne")
+BUILTIN(__builtin_casin, "XdXd", "Fne")
+BUILTIN(__builtin_casinf, "XfXf", "Fne")
+BUILTIN(__builtin_casinh, "XdXd", "Fne")
+BUILTIN(__builtin_casinhf, "XfXf", "Fne")
+BUILTIN(__builtin_casinhl, "XLdXLd", "Fne")
+BUILTIN(__builtin_casinl, "XLdXLd", "Fne")
+BUILTIN(__builtin_catan, "XdXd", "Fne")
+BUILTIN(__builtin_catanf, "XfXf", "Fne")
+BUILTIN(__builtin_catanh, "XdXd", "Fne")
+BUILTIN(__builtin_catanhf, "XfXf", "Fne")
+BUILTIN(__builtin_catanhl, "XLdXLd", "Fne")
+BUILTIN(__builtin_catanl, "XLdXLd", "Fne")
+BUILTIN(__builtin_ccos, "XdXd", "Fne")
+BUILTIN(__builtin_ccosf, "XfXf", "Fne")
+BUILTIN(__builtin_ccosl, "XLdXLd", "Fne")
+BUILTIN(__builtin_ccosh, "XdXd", "Fne")
+BUILTIN(__builtin_ccoshf, "XfXf", "Fne")
+BUILTIN(__builtin_ccoshl, "XLdXLd", "Fne")
+BUILTIN(__builtin_cexp, "XdXd", "Fne")
+BUILTIN(__builtin_cexpf, "XfXf", "Fne")
+BUILTIN(__builtin_cexpl, "XLdXLd", "Fne")
 BUILTIN(__builtin_cimag, "dXd", "Fnc")
 BUILTIN(__builtin_cimagf, "fXf", "Fnc")
 BUILTIN(__builtin_cimagl, "LdXLd", "Fnc")
 BUILTIN(__builtin_conj, "XdXd", "Fnc")
 BUILTIN(__builtin_conjf, "XfXf", "Fnc")
 BUILTIN(__builtin_conjl, "XLdXLd", "Fnc")
-BUILTIN(__builtin_clog, "XdXd", "Fnc")
-BUILTIN(__builtin_clogf, "XfXf", "Fnc")
-BUILTIN(__builtin_clogl, "XLdXLd", "Fnc")
+BUILTIN(__builtin_clog, "XdXd", "Fne")
+BUILTIN(__builtin_clogf, "XfXf", "Fne")
+BUILTIN(__builtin_clogl, "XLdXLd", "Fne")
 BUILTIN(__builtin_cproj, "XdXd", "Fnc")
 BUILTIN(__builtin_cprojf, "XfXf", "Fnc")
 BUILTIN(__builtin_cprojl, "XLdXLd", "Fnc")
-BUILTIN(__builtin_cpow, "XdXdXd", "Fnc")

[PATCH] D5767: Template Instantiation Observer + a few other templight-related changes

2017-11-18 Thread Ábel Sinkovics via Phabricator via cfe-commits
sabel83 updated this revision to Diff 123465.
Herald added a subscriber: rnkovacs.

https://reviews.llvm.org/D5767

Files:
  include/clang/Driver/CC1Options.td
  include/clang/Frontend/FrontendActions.h
  include/clang/Frontend/FrontendOptions.h
  include/clang/FrontendTool/Utils.h
  include/clang/Sema/Sema.h
  include/clang/Sema/TemplateInstCallback.h
  lib/Frontend/CompilerInvocation.cpp
  lib/Frontend/FrontendActions.cpp
  lib/FrontendTool/ExecuteCompilerInvocation.cpp
  lib/Parse/ParseAST.cpp
  lib/Sema/Sema.cpp
  lib/Sema/SemaTemplateInstantiate.cpp
  lib/Sema/SemaTemplateInstantiateDecl.cpp
  lib/Sema/SemaType.cpp
  test/Templight/templight-deduced-func.cpp
  test/Templight/templight-default-arg-inst.cpp
  test/Templight/templight-default-func-arg.cpp
  test/Templight/templight-default-template-arg.cpp
  test/Templight/templight-exception-spec-func.cpp
  test/Templight/templight-explicit-template-arg.cpp
  test/Templight/templight-memoization.cpp
  test/Templight/templight-nested-memoization.cpp
  test/Templight/templight-nested-template-instantiation.cpp
  test/Templight/templight-one-instantiation.cpp
  test/Templight/templight-prior-template-arg.cpp

Index: test/Templight/templight-prior-template-arg.cpp
===
--- test/Templight/templight-prior-template-arg.cpp
+++ test/Templight/templight-prior-template-arg.cpp
@@ -0,0 +1,62 @@
+// RUN: %clang_cc1 -templight-dump %s 2>&1 | FileCheck %s
+template
+class A {};
+
+template  class Outer>
+class B {};
+
+// CHECK-LABEL: {{^---$}}
+// CHECK: {{^name:[ ]+'B::Outer'$}}
+// CHECK: {{^kind:[ ]+PriorTemplateArgumentSubstitution$}}
+// CHECK: {{^event:[ ]+Begin$}}
+// CHECK: {{^poi:[ ]+'.*templight-prior-template-arg.cpp:}}[[@LINE+50]]{{:1'$}}
+// CHECK-LABEL: {{^---$}}
+// CHECK: {{^name:[ ]+'B::Outer'$}}
+// CHECK: {{^kind:[ ]+PriorTemplateArgumentSubstitution$}}
+// CHECK: {{^event:[ ]+End$}}
+// CHECK: {{^poi:[ ]+'.*templight-prior-template-arg.cpp:}}[[@LINE+45]]{{:1'$}}
+//
+// CHECK-LABEL: {{^---$}}
+// CHECK: {{^name:[ ]+'B'$}}
+// CHECK: {{^kind:[ ]+TemplateInstantiation$}}
+// CHECK: {{^event:[ ]+Begin$}}
+// CHECK: {{^poi:[ ]+'.*templight-prior-template-arg.cpp:}}[[@LINE+39]]{{:6'$}}
+// CHECK-LABEL: {{^---$}}
+// CHECK: {{^name:[ ]+'B'$}}
+// CHECK: {{^kind:[ ]+TemplateInstantiation$}}
+// CHECK: {{^event:[ ]+End$}}
+// CHECK: {{^poi:[ ]+'.*templight-prior-template-arg.cpp:}}[[@LINE+34]]{{:6'$}}
+//
+// CHECK-LABEL: {{^---$}}
+// CHECK: {{^name:[ ]+'B'$}}
+// CHECK: {{^kind:[ ]+TemplateInstantiation$}}
+// CHECK: {{^event:[ ]+Begin$}}
+// CHECK: {{^poi:[ ]+'.*templight-prior-template-arg.cpp:}}[[@LINE+28]]{{:6'$}}
+// CHECK-LABEL: {{^---$}}
+// CHECK: {{^name:[ ]+'B'$}}
+// CHECK: {{^kind:[ ]+TemplateInstantiation$}}
+// CHECK: {{^event:[ ]+End$}}
+// CHECK: {{^poi:[ ]+'.*templight-prior-template-arg.cpp:}}[[@LINE+23]]{{:6'$}}
+//
+// CHECK-LABEL: {{^---$}}
+// CHECK: {{^name:[ ]+'B'$}}
+// CHECK: {{^kind:[ ]+Memoization$}}
+// CHECK: {{^event:[ ]+Begin$}}
+// CHECK: {{^poi:[ ]+'.*templight-prior-template-arg.cpp:}}[[@LINE+17]]{{:6'$}}
+// CHECK-LABEL: {{^---$}}
+// CHECK: {{^name:[ ]+'B'$}}
+// CHECK: {{^kind:[ ]+Memoization$}}
+// CHECK: {{^event:[ ]+End$}}
+// CHECK: {{^poi:[ ]+'.*templight-prior-template-arg.cpp:}}[[@LINE+12]]{{:6'$}}
+//
+// CHECK-LABEL: {{^---$}}
+// CHECK: {{^name:[ ]+'B'$}}
+// CHECK: {{^kind:[ ]+Memoization$}}
+// CHECK: {{^event:[ ]+Begin$}}
+// CHECK: {{^poi:[ ]+'.*templight-prior-template-arg.cpp:}}[[@LINE+6]]{{:6'$}}
+// CHECK-LABEL: {{^---$}}
+// CHECK: {{^name:[ ]+'B'$}}
+// CHECK: {{^kind:[ ]+Memoization$}}
+// CHECK: {{^event:[ ]+End$}}
+// CHECK: {{^poi:[ ]+'.*templight-prior-template-arg.cpp:}}[[@LINE+1]]{{:6'$}}
+B b;
Index: test/Templight/templight-one-instantiation.cpp
===
--- test/Templight/templight-one-instantiation.cpp
+++ test/Templight/templight-one-instantiation.cpp
@@ -0,0 +1,16 @@
+// RUN: %clang_cc1 -templight-dump %s 2>&1 | FileCheck %s
+
+template 
+struct foo {};
+
+// CHECK-LABEL: {{^---$}}
+// CHECK: {{^name:[ ]+'foo'$}}
+// CHECK: {{^kind:[ ]+TemplateInstantiation$}}
+// CHECK: {{^event:[ ]+Begin$}}
+// CHECK: {{^poi:[ ]+'.*templight-one-instantiation.cpp:}}[[@LINE+6]]{{:10'$}}
+// CHECK-LABEL: {{^---$}}
+// CHECK: {{^name:[ ]+'foo'$}}
+// CHECK: {{^kind:[ ]+TemplateInstantiation$}}
+// CHECK: {{^event:[ ]+End$}}
+// CHECK: {{^poi:[ ]+'.*templight-one-instantiation.cpp:}}[[@LINE+1]]{{:10'$}}
+foo x;
Index: test/Templight/templight-nested-template-instantiation.cpp
===
--- test/Templight/templight-nested-template-instantiation.cpp
+++ test/Templight/templight-nested-template-instantiation.cpp
@@ -0,0 +1,72 @@
+// RUN: %clang_cc1 -templight-dump %s 2>&1 | FileCheck %s
+
+template 
+struct foo : foo {};
+
+template <>
+struct foo<0> {};
+
+// CHECK-LABEL: {{^---$}}
+// CHECK: {{^name:[ ]+'foo<2>'$}}
+// 

[PATCH] D40108: [clang-tidy] Adding Fuchsia checkers to clang-tidy

2017-11-18 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman requested changes to this revision.
aaron.ballman added a comment.
This revision now requires changes to proceed.

Thank you for the explanation about what is driving this and the documentation. 
I don't think google-* is the correct module for this as it's too general of an 
umbrella. I have a slight preference for zircon-* because this appears to be 
specific to that particular project.




Comment at: clang-tidy/fuchsia/DefaultArgumentsCheck.cpp:18
+
+AST_MATCHER(ParmVarDecl, hasDefaultArgument) { return Node.hasDefaultArg(); }
+

I think this should be put into ASTMatchers.h as a separate patch (feel free to 
list me as a reviewer). See D39940 for an example of how to do that, but the 
only non-obvious task is running clang\docs\tools\dump_ast_matchers.py to 
generate the HTML from ASTMatchers.h.



Comment at: clang-tidy/fuchsia/DefaultArgumentsCheck.cpp:22
+  // Calling a function which uses default arguments is disallowed.
+  Finder->addMatcher(cxxDefaultArgExpr().bind("stmt"), this);
+  // Declaring default parameters is disallowed.

Isn't this case already covered by the other matcher? Or do you have system 
header files which have default arguments and those functions are disallowed by 
the style guide, but cannot be removed from the system header?



Comment at: clang-tidy/fuchsia/DefaultArgumentsCheck.cpp:28
+void DefaultArgumentsCheck::check(const MatchFinder::MatchResult ) {
+  if (const CXXDefaultArgExpr *S =
+  Result.Nodes.getNodeAs("stmt")) {

You can use `const auto *` here instead of spelling the type out twice.



Comment at: clang-tidy/fuchsia/DefaultArgumentsCheck.cpp:36
+diag(D->getLocStart(),
+ "declaring functions which use default arguments is disallowed");
+  }

Would it make sense to add a fix-it that removes the intializer for the default 
argument?



Comment at: docs/clang-tidy/checks/fuchsia-default-arguments.rst:8
+
+Example: The declaration:
+

Eugene.Zelenko wrote:
> I briefly look on other checks documentation, so will be good idea to use 
> just //Example:// or //For example, the declaration:// . But will be good 
> idea to hear opinion of native English speaker.
I'd go with: `For example, the declaration:`



Comment at: docs/clang-tidy/index.rst:672
   will run clang-format over changed lines.
-

Spurious newline removal?


https://reviews.llvm.org/D40108



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


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

2017-11-18 Thread Raoul Wols via Phabricator via cfe-commits
rwols added inline comments.



Comment at: clangd/ClangdServer.h:289
+  llvm::Expected
+  formatRange(llvm::StringRef Code, PathRef File, Range Rng);
+

rwols wrote:
> ilya-biryukov wrote:
> > rwols wrote:
> > > ilya-biryukov wrote:
> > > > Why do we accept `Code` as a parameter here instead of getting it 
> > > > internally?
> > > > 
> > > > Maybe we should consider moving this method out of `ClangdServer`? Its 
> > > > signature looks pretty self-contained now.
> > > There are a couple intertwined problems:
> > > 
> > > 1. replacementsToEdits wants llvm::StringRef Code
> > > 2. ClangdServer::formatCode wants llvm::StringRef Code
> > > 3. ClangdServer::getDocument returns an std::string
> > > 
> > > So yes, in principle you can call getDocument when you need it for 
> > > replacementsToEdits, and you can let formatCode itself call getDocument 
> > > for clang::format::getStyle. But then we create two copies of the 
> > > document contents for one LSP request.
> > > 
> > > If getDocument returned an llvm::StringRef, I'd probably vote for 
> > > removing the Code argument everywhere and call getDocument as needed.
> > Oh, I see. Calling `getDocument` twice does not really make sense.  
> > Maybe we could move a call to `replacementsToEdits` into `formatOnFile` and 
> > make it return `vector`?  Seems to be solving both problems.
> > 
> > We could've made `getDocument` return `StringRef`, but we'd have to be more 
> > careful to ensure it's actually copied when we're scheduling async 
> > operations, worth a separate review.
> > Maybe we could move a call to replacementsToEdits into formatOnFile and 
> > make it return vector?
> 
> I disagree, this will bring LSP-specific protocols into `ClangdServer`. The 
> translation from `tooling::Replacement` to `clangd::TextEdit` should remain 
> in `ClangdLSPServer`.
I tried this anyway, but `ClangdLSPServer::getFixIts` also uses 
`replacementsToEdits`. And that maintains a map with `tooling::Replacement`s. 
So, if we want to move `replacementsToEdits` into `ClangdServer`, we would have 
to move that map into `ClangdServer` too I think.


https://reviews.llvm.org/D39430



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


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

2017-11-18 Thread Raoul Wols via Phabricator via cfe-commits
rwols added inline comments.



Comment at: clangd/ClangdServer.h:289
+  llvm::Expected
+  formatRange(llvm::StringRef Code, PathRef File, Range Rng);
+

ilya-biryukov wrote:
> rwols wrote:
> > ilya-biryukov wrote:
> > > Why do we accept `Code` as a parameter here instead of getting it 
> > > internally?
> > > 
> > > Maybe we should consider moving this method out of `ClangdServer`? Its 
> > > signature looks pretty self-contained now.
> > There are a couple intertwined problems:
> > 
> > 1. replacementsToEdits wants llvm::StringRef Code
> > 2. ClangdServer::formatCode wants llvm::StringRef Code
> > 3. ClangdServer::getDocument returns an std::string
> > 
> > So yes, in principle you can call getDocument when you need it for 
> > replacementsToEdits, and you can let formatCode itself call getDocument for 
> > clang::format::getStyle. But then we create two copies of the document 
> > contents for one LSP request.
> > 
> > If getDocument returned an llvm::StringRef, I'd probably vote for removing 
> > the Code argument everywhere and call getDocument as needed.
> Oh, I see. Calling `getDocument` twice does not really make sense.  
> Maybe we could move a call to `replacementsToEdits` into `formatOnFile` and 
> make it return `vector`?  Seems to be solving both problems.
> 
> We could've made `getDocument` return `StringRef`, but we'd have to be more 
> careful to ensure it's actually copied when we're scheduling async 
> operations, worth a separate review.
> Maybe we could move a call to replacementsToEdits into formatOnFile and make 
> it return vector?

I disagree, this will bring LSP-specific protocols into `ClangdServer`. The 
translation from `tooling::Replacement` to `clangd::TextEdit` should remain in 
`ClangdLSPServer`.


https://reviews.llvm.org/D39430



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


[PATCH] D39955: [Driver] Add a cc1 flag for the new TBAA metadata format

2017-11-18 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.

LGTM.


https://reviews.llvm.org/D39955



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


[PATCH] D39627: Fix vtable not receiving hidden visibility when using push(visibility)

2017-11-18 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.

Looks great, thanks!


Repository:
  rL LLVM

https://reviews.llvm.org/D39627



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


[PATCH] D39505: [OpenMP] Show error if VLAs are not supported

2017-11-18 Thread John McCall via Phabricator via cfe-commits
rjmccall accepted this revision.
rjmccall added a comment.
This revision is now accepted and ready to land.

Okay, seems fine.  Thanks for putting up with my questions.


https://reviews.llvm.org/D39505



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