[PATCH] D28174: [libcxx] [NFC] Rename _LIBCPP_TYPE_VIS_ONLY to _LIBCPP_TEMPLATE_VIS.

2016-12-29 Thread Eric Fiselier via Phabricator via cfe-commits
EricWF added a comment.

In https://reviews.llvm.org/D28174#632662, @smeenai wrote:

> As you're aware, I have plans to change `_LIBCPP_TYPE_VIS` to expand to 
> `visibility` instead of `type_visibility`.


I had forgotten. Thanks for the reminder.

> but I still think this rename makes sense.

Awesome, Thanks!


https://reviews.llvm.org/D28174



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


[PATCH] D28148: [Sema] Suppress warnings for C's zero initializer

2016-12-29 Thread S. Gilles via Phabricator via cfe-commits
sgilles updated this revision to Diff 82720.
sgilles added a comment.

Address rsmith's comments, in particular: factor out testing zero initializers 
to a method of `InitListExpr`; use `ParentIList` instead of 
`StructuredSubobjectInitList`.

The warning is (still) not relaxed for C++ code.  I have no opinion on this 
beyond wanting to avoid regressions, but for lack of consensus I'll default to 
changing as little as possible.


https://reviews.llvm.org/D28148

Files:
  include/clang/AST/Expr.h
  lib/AST/Expr.cpp
  lib/Sema/SemaInit.cpp
  test/Sema/zero-initializer.c


Index: test/Sema/zero-initializer.c
===
--- /dev/null
+++ test/Sema/zero-initializer.c
@@ -0,0 +1,26 @@
+// RUN: %clang_cc1 -std=c99 -Wmissing-field-initializers -Wmissing-braces
+
+struct foo { int x; int y; };
+struct bar { struct foo a; struct foo b; };
+struct A { int a; }
+struct B { struct A a; }
+struct C { struct B b; }
+
+int main(void)
+{
+  struct foo f = { 0 }; // expected-no-diagnostics
+  struct foo g = { 9 }; // expected-warning {{missing field 'y' initializer}}
+  struct foo h = { 9, 9 }; // expected-no-diagnostics
+  struct bar i = { 0 }; // expected-no-diagnostics
+  struct bar j = { 0, 0 }; // expected-warning {{suggest braces around 
initialization of suboject}} expected-warning {{missing field 'b' initializer}}
+  struct bar k = { { 9, 9 }, { 9, 9 } }; // expected-no-diagnostics
+  struct bar l = { { 9, 9 }, { 0 } }; // expected-no-diagnostics
+  struct bar m = { { 0 }, { 0 } }; // expected-no-diagnostics
+  struct bar n = { { 0 }, { 9, 9 } }; // expected-no-diagnostics
+  struct bar o = { { 9, 9 }, { 0 } }; // expected-no-diagnostics
+  struct bar p = { { 9 }, { 9, 9 } }; // expected-warning {{missing field 'y' 
initializer}}
+  struct C q = { 0 }; // expected-no-diagnostics
+  struct C r = { 9 }; // expected-warning {{suggest braces around 
initialization of suboject}}
+
+  return 0;
+}
Index: lib/Sema/SemaInit.cpp
===
--- lib/Sema/SemaInit.cpp
+++ lib/Sema/SemaInit.cpp
@@ -881,7 +881,8 @@
 }
 
 // Complain about missing braces.
-if (T->isArrayType() || T->isRecordType()) {
+if ((T->isArrayType() || T->isRecordType()) &&
+!ParentIList->isIdiomaticZeroInitializer(SemaRef.getLangOpts())) {
   SemaRef.Diag(StructuredSubobjectInitList->getLocStart(),
diag::warn_missing_braces)
   << StructuredSubobjectInitList->getSourceRange()
@@ -1827,7 +1828,9 @@
   // worthwhile to skip over the rest of the initializer, though.
   RecordDecl *RD = DeclType->getAs()->getDecl();
   RecordDecl::field_iterator FieldEnd = RD->field_end();
-  bool CheckForMissingFields = true;
+  bool CheckForMissingFields =
+!IList->isIdiomaticZeroInitializer(SemaRef.getLangOpts());
+
   while (Index < IList->getNumInits()) {
 Expr *Init = IList->getInit(Index);
 
Index: lib/AST/Expr.cpp
===
--- lib/AST/Expr.cpp
+++ lib/AST/Expr.cpp
@@ -1883,6 +1883,21 @@
  getInit(0)->getType().getCanonicalType();
 }
 
+bool InitListExpr::isIdiomaticZeroInitializer(const LangOptions ) 
const {
+  assert(!getSyntacticForm() && "only test syntactic form as zero 
initializer");
+
+  if (LangOpts.CPlusPlus || getNumInits() != 1) {
+return false;
+  }
+
+  const IntegerLiteral *lit = dyn_cast(getInit(0));
+  if (!lit) {
+return false;
+  }
+
+  return lit->getValue() == 0;
+}
+
 SourceLocation InitListExpr::getLocStart() const {
   if (InitListExpr *SyntacticForm = getSyntacticForm())
 return SyntacticForm->getLocStart();
Index: include/clang/AST/Expr.h
===
--- include/clang/AST/Expr.h
+++ include/clang/AST/Expr.h
@@ -3899,6 +3899,10 @@
   /// initializer)?
   bool isTransparent() const;
 
+  /// Is this the zero initializer {0} in a language which considers it
+  /// idiomatic?
+  bool isIdiomaticZeroInitializer(const LangOptions ) const;
+
   SourceLocation getLBraceLoc() const { return LBraceLoc; }
   void setLBraceLoc(SourceLocation Loc) { LBraceLoc = Loc; }
   SourceLocation getRBraceLoc() const { return RBraceLoc; }


Index: test/Sema/zero-initializer.c
===
--- /dev/null
+++ test/Sema/zero-initializer.c
@@ -0,0 +1,26 @@
+// RUN: %clang_cc1 -std=c99 -Wmissing-field-initializers -Wmissing-braces
+
+struct foo { int x; int y; };
+struct bar { struct foo a; struct foo b; };
+struct A { int a; }
+struct B { struct A a; }
+struct C { struct B b; }
+
+int main(void)
+{
+  struct foo f = { 0 }; // expected-no-diagnostics
+  struct foo g = { 9 }; // expected-warning {{missing field 'y' initializer}}
+  struct foo h = { 9, 9 }; // expected-no-diagnostics
+  struct bar i = { 0 }; // expected-no-diagnostics
+  struct bar j = { 0, 0 }; // expected-warning {{suggest braces around 

[PATCH] D28174: [libcxx] [NFC] Rename _LIBCPP_TYPE_VIS_ONLY to _LIBCPP_TEMPLATE_VIS.

2016-12-29 Thread Shoaib Meenai via Phabricator via cfe-commits
smeenai added a comment.

As you're aware, I have plans to change `_LIBCPP_TYPE_VIS` to expand to 
`visibility` instead of `type_visibility`, but I still think this rename makes 
sense.


https://reviews.llvm.org/D28174



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


[PATCH] D27430: [libc++] Annotate template methods with visibility

2016-12-29 Thread Eric Fiselier via Phabricator via cfe-commits
EricWF added a comment.

Please put these attributes to the first declaration instead of the definition.




Comment at: include/thread:392
 template 
+_LIBCPP_HIDDEN
 thread::thread(_Fp __f)

We really should hide this using `inline _LIBCPP_INLINE_VISIBILITY` because 
it's a special C++03 symbol, so we don't even want a hidden definition omitted 
ideally.


https://reviews.llvm.org/D27430



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


[PATCH] D26949: [libc++abi] Clean up visibility

2016-12-29 Thread Eric Fiselier via Phabricator via cfe-commits
EricWF added inline comments.



Comment at: src/abort_message.cpp:25
 
-#pragma GCC visibility push(hidden)
-

Is this really redundant? There is an `#include ` after 
it. Is this not going to affect those symbols?



Comment at: src/cxa_handlers.hpp:23
 
-__attribute__((visibility("hidden"), noreturn))
+_LIBCXXABI_HIDDEN __attribute__((noreturn))
 void

`_LIBCXXABI_HIDDEN LIBCXXABI_NORETURN`?



Comment at: src/cxa_handlers.hpp:27
 
-__attribute__((visibility("hidden"), noreturn))
+_LIBCXXABI_HIDDEN __attribute__((noreturn))
 void

`_LIBCXXABI_HIDDEN LIBCXXABI_NORETURN`?



Comment at: src/cxa_new_delete.cpp:34
 */
-__attribute__((__weak__, __visibility__("default")))
+__attribute__((__weak__))
 void *

Can we abstract this away to a `_LIBCXXABI_NEW_DELETE_VIS` macro?


https://reviews.llvm.org/D26949



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


[PATCH] D26830: [libcxx] Add string_view literals

2016-12-29 Thread Eric Fiselier via Phabricator via cfe-commits
EricWF added a comment.

Alright. I committed the Clang changes. Just re-building now so I can test this.




Comment at: include/string_view:780
+} // namespace literals
+#endif
+

`// _LIBCPP_STD_VER > 14` comment please.



Comment at: 
test/std/strings/string.view/string.view.literals/literal1.pass.cpp:16
+
+int main()
+{

What's the point of this test that `literal.pass.cpp` doesn't cover?



Comment at: 
test/std/strings/string.view/string.view.literals/literal2.pass.cpp:16
+
+int main()
+{

What's the point of this test that `literal.pass.cpp` doesn't cover?


https://reviews.llvm.org/D26830



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


[PATCH] D26829: [clang] Allow lexer to handle string_view literals

2016-12-29 Thread Eric Fiselier via Phabricator via cfe-commits
EricWF closed this revision.
EricWF added a comment.

Committed on behalf of @AntonBikineev in r290744.


https://reviews.llvm.org/D26829



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


r290744 - Allow lexer to handle string_view literals. Patch from Anton Bikineev.

2016-12-29 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Thu Dec 29 22:51:10 2016
New Revision: 290744

URL: http://llvm.org/viewvc/llvm-project?rev=290744=rev
Log:
Allow lexer to handle string_view literals. Patch from Anton Bikineev.

This implements the compiler side of p0403r0. This patch was reviewed as
https://reviews.llvm.org/D26829.

Added:
cfe/trunk/test/SemaCXX/cxx1z-user-defined-literals.cpp
Modified:
cfe/trunk/include/clang/Lex/LiteralSupport.h
cfe/trunk/lib/Lex/Lexer.cpp
cfe/trunk/lib/Lex/LiteralSupport.cpp
cfe/trunk/lib/Sema/SemaDeclCXX.cpp

Modified: cfe/trunk/include/clang/Lex/LiteralSupport.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Lex/LiteralSupport.h?rev=290744=290743=290744=diff
==
--- cfe/trunk/include/clang/Lex/LiteralSupport.h (original)
+++ cfe/trunk/include/clang/Lex/LiteralSupport.h Thu Dec 29 22:51:10 2016
@@ -259,6 +259,8 @@ public:
 return UDSuffixOffset;
   }
 
+  static bool isValidUDSuffix(const LangOptions , StringRef Suffix);
+
 private:
   void init(ArrayRef StringToks);
   bool CopyStringFragment(const Token , const char *TokBegin,

Modified: cfe/trunk/lib/Lex/Lexer.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/Lexer.cpp?rev=290744=290743=290744=diff
==
--- cfe/trunk/lib/Lex/Lexer.cpp (original)
+++ cfe/trunk/lib/Lex/Lexer.cpp Thu Dec 29 22:51:10 2016
@@ -1713,9 +1713,9 @@ const char *Lexer::LexUDSuffix(Token 
  getLangOpts());
 if (!isIdentifierBody(Next)) {
   // End of suffix. Check whether this is on the whitelist.
-  IsUDSuffix = (Chars == 1 && Buffer[0] == 's') ||
-   NumericLiteralParser::isValidUDSuffix(
-   getLangOpts(), StringRef(Buffer, Chars));
+  const StringRef CompleteSuffix(Buffer, Chars);
+  IsUDSuffix = StringLiteralParser::isValidUDSuffix(getLangOpts(),
+CompleteSuffix);
   break;
 }
 

Modified: cfe/trunk/lib/Lex/LiteralSupport.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/LiteralSupport.cpp?rev=290744=290743=290744=diff
==
--- cfe/trunk/lib/Lex/LiteralSupport.cpp (original)
+++ cfe/trunk/lib/Lex/LiteralSupport.cpp Thu Dec 29 22:51:10 2016
@@ -1708,3 +1708,12 @@ unsigned StringLiteralParser::getOffsetO
 
   return SpellingPtr-SpellingStart;
 }
+
+/// Determine whether a suffix is a valid ud-suffix. We avoid treating reserved
+/// suffixes as ud-suffixes, because the diagnostic experience is better if we
+/// treat it as an invalid suffix.
+bool StringLiteralParser::isValidUDSuffix(const LangOptions ,
+  StringRef Suffix) {
+  return NumericLiteralParser::isValidUDSuffix(LangOpts, Suffix) ||
+ Suffix == "sv";
+}

Modified: cfe/trunk/lib/Sema/SemaDeclCXX.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclCXX.cpp?rev=290744=290743=290744=diff
==
--- cfe/trunk/lib/Sema/SemaDeclCXX.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclCXX.cpp Thu Dec 29 22:51:10 2016
@@ -12913,7 +12913,7 @@ bool Sema::CheckLiteralOperatorDeclarati
 //   Literal suffix identifiers that do not start with an underscore
 //   are reserved for future standardization.
 Diag(FnDecl->getLocation(), diag::warn_user_literal_reserved)
-  << NumericLiteralParser::isValidUDSuffix(getLangOpts(), LiteralName);
+  << StringLiteralParser::isValidUDSuffix(getLangOpts(), LiteralName);
   }
 
   return false;

Added: cfe/trunk/test/SemaCXX/cxx1z-user-defined-literals.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/cxx1z-user-defined-literals.cpp?rev=290744=auto
==
--- cfe/trunk/test/SemaCXX/cxx1z-user-defined-literals.cpp (added)
+++ cfe/trunk/test/SemaCXX/cxx1z-user-defined-literals.cpp Thu Dec 29 22:51:10 
2016
@@ -0,0 +1,21 @@
+// RUN: %clang_cc1 -std=c++1z %s -include %s -verify
+
+#ifndef INCLUDED
+#define INCLUDED
+
+#pragma clang system_header
+namespace std {
+  using size_t = decltype(sizeof(0));
+
+  struct string_view {};
+  string_view operator""sv(const char*, size_t);
+}
+
+#else
+
+using namespace std;
+string_view s = "foo"sv;
+const char* p = "bar"sv; // expected-error {{no viable conversion}}
+char error = 'x'sv; // expected-error {{invalid suffix}} expected-error 
{{expected ';'}}
+
+#endif


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


[PATCH] D28172: [libcxx] Remove unexpected handlers in C++17

2016-12-29 Thread Eric Fiselier via Phabricator via cfe-commits
EricWF created this revision.
EricWF added a reviewer: mclow.lists.
EricWF added subscribers: cfe-commits, mclow.lists.

This patch implements P0003R5 
 which 
removes exception specifications from C++17.

The only changes to the library are removing `set_unexpected`, 
`get_unexpected`, `unexpected`, and `unexpected_handler`. These functions can 
be re-enabled in C++17 using 
`_LIBCPP_ENABLE_CXX17_REMOVED_UNEXPECTED_FUNCTIONS`.

@mclow.lists what do you think about removing stuff is this way?


https://reviews.llvm.org/D28172

Files:
  docs/UsingLibcxx.rst
  include/exception
  test/libcxx/depr/exception.unexpected/get_unexpected.pass.cpp
  test/libcxx/depr/exception.unexpected/set_unexpected.pass.cpp
  test/libcxx/depr/exception.unexpected/unexpected.pass.cpp
  test/libcxx/depr/exception.unexpected/unexpected_disabled_cpp17.fail.cpp
  test/std/depr/exception.unexpected/set.unexpected/get_unexpected.pass.cpp
  test/std/depr/exception.unexpected/set.unexpected/set_unexpected.pass.cpp
  
test/std/depr/exception.unexpected/unexpected.handler/unexpected_handler.pass.cpp
  test/std/depr/exception.unexpected/unexpected/unexpected.pass.cpp
  www/cxx1z_status.html

Index: www/cxx1z_status.html
===
--- www/cxx1z_status.html
+++ www/cxx1z_status.html
@@ -122,7 +122,7 @@
 	http://wg21.link/p0393r3;>p0393r3LWGMaking Variant Greater EqualOuluComplete4.0
 	http://wg21.link/P0394r4;>P0394r4LWGHotel Parallelifornia: terminate() for Parallel Algorithms Exception HandlingOulu
   	
-	http://wg21.link/P0003R5;>P0003R5LWGRemoving Deprecated Exception Specifications from C++17Issaquah
+	http://wg21.link/P0003R5;>P0003R5LWGRemoving Deprecated Exception Specifications from C++17IssaquahComplete4.0
 	http://wg21.link/P0067R5;>P0067R5LWGElementary string conversions, revision 5Issaquah
 	http://wg21.link/P0403R1;>P0403R1LWGLiteral suffixes for basic_string_viewIssaquah
 	http://wg21.link/P0414R2;>P0414R2LWGMerging shared_ptr changes from Library Fundamentals to C++17Issaquah
Index: test/std/depr/exception.unexpected/unexpected/unexpected.pass.cpp
===
--- test/std/depr/exception.unexpected/unexpected/unexpected.pass.cpp
+++ test/std/depr/exception.unexpected/unexpected/unexpected.pass.cpp
@@ -7,6 +7,8 @@
 //
 //===--===//
 
+// REQUIRES-ANY: c++98, c++03, c++11, c++14
+
 // test unexpected
 
 #include 
Index: test/std/depr/exception.unexpected/unexpected.handler/unexpected_handler.pass.cpp
===
--- test/std/depr/exception.unexpected/unexpected.handler/unexpected_handler.pass.cpp
+++ test/std/depr/exception.unexpected/unexpected.handler/unexpected_handler.pass.cpp
@@ -7,6 +7,8 @@
 //
 //===--===//
 
+// REQUIRES-ANY: c++98, c++03, c++11, c++14
+
 // test unexpected_handler
 
 #include 
Index: test/std/depr/exception.unexpected/set.unexpected/set_unexpected.pass.cpp
===
--- test/std/depr/exception.unexpected/set.unexpected/set_unexpected.pass.cpp
+++ test/std/depr/exception.unexpected/set.unexpected/set_unexpected.pass.cpp
@@ -7,6 +7,8 @@
 //
 //===--===//
 
+// REQUIRES-ANY: c++98, c++03, c++11, c++14
+
 // test set_unexpected
 
 #include 
Index: test/std/depr/exception.unexpected/set.unexpected/get_unexpected.pass.cpp
===
--- test/std/depr/exception.unexpected/set.unexpected/get_unexpected.pass.cpp
+++ test/std/depr/exception.unexpected/set.unexpected/get_unexpected.pass.cpp
@@ -7,6 +7,8 @@
 //
 //===--===//
 
+// REQUIRES-ANY: c++98, c++03, c++11, c++14
+
 // test get_unexpected
 
 #include 
Index: test/libcxx/depr/exception.unexpected/unexpected_disabled_cpp17.fail.cpp
===
--- /dev/null
+++ test/libcxx/depr/exception.unexpected/unexpected_disabled_cpp17.fail.cpp
@@ -0,0 +1,23 @@
+//===--===//
+//
+// 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
+
+// test unexpected
+
+#include 
+
+void f() {}
+
+int main() {
+  using T = std::unexpected_handler; // expected-error {{no type named 'unexpected_handler' in namespace 'std'}}
+  std::unexpected(); // expected-error {{no member named 

r290743 - Remove bogus assertion and add testcase that triggers it.

2016-12-29 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Thu Dec 29 22:32:02 2016
New Revision: 290743

URL: http://llvm.org/viewvc/llvm-project?rev=290743=rev
Log:
Remove bogus assertion and add testcase that triggers it.

Modified:
cfe/trunk/lib/Sema/SemaTemplateDeduction.cpp
cfe/trunk/test/SemaTemplate/temp_arg_nontype.cpp

Modified: cfe/trunk/lib/Sema/SemaTemplateDeduction.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaTemplateDeduction.cpp?rev=290743=290742=290743=diff
==
--- cfe/trunk/lib/Sema/SemaTemplateDeduction.cpp (original)
+++ cfe/trunk/lib/Sema/SemaTemplateDeduction.cpp Thu Dec 29 22:32:02 2016
@@ -380,8 +380,6 @@ static Sema::TemplateDeductionResult Ded
 Sema , TemplateParameterList *TemplateParams,
 NonTypeTemplateParmDecl *NTTP, Expr *Value, TemplateDeductionInfo ,
 SmallVectorImpl ) {
-  assert((Value->isTypeDependent() || Value->isValueDependent()) &&
- "Expression template argument must be type- or value-dependent.");
   return DeduceNonTypeTemplateArgument(S, TemplateParams, NTTP,
DeducedTemplateArgument(Value),
Value->getType(), Info, Deduced);
@@ -4363,6 +4361,10 @@ static bool isAtLeastAsSpecializedAs(Sem
 if (Deduced[ArgIdx].isNull())
   break;
 
+  // FIXME: We fail to implement [temp.deduct.type]p1 along this path. We need
+  // to substitute the deduced arguments back into the template and check that
+  // we get the right type.
+
   if (ArgIdx == NumArgs) {
 // All template arguments were deduced. FT1 is at least as specialized
 // as FT2.

Modified: cfe/trunk/test/SemaTemplate/temp_arg_nontype.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaTemplate/temp_arg_nontype.cpp?rev=290743=290742=290743=diff
==
--- cfe/trunk/test/SemaTemplate/temp_arg_nontype.cpp (original)
+++ cfe/trunk/test/SemaTemplate/temp_arg_nontype.cpp Thu Dec 29 22:32:02 2016
@@ -434,3 +434,20 @@ namespace dependent_nested_partial_speci
   };
   E::F e1; // expected-note {{instantiation of}}
 }
+
+namespace nondependent_default_arg_ordering {
+  int n, m;
+  template struct X {};
+  template void f(X); // expected-note {{candidate}}
+  template void f(X); // expected-note {{candidate}}
+  template void f(X); // expected-note 2{{candidate}}
+  template