dim created this revision.

In https://reviews.llvm.org/D41064, I proposed adding `#pragma clang diagnostic 
ignored
"-Wuser-defined-literals"` to some of libc++'s headers, since these
warnings are now triggered by clang's new `-std=gnu++14` default:

  $ cat test.cpp
  #include <string>
  
  $ clang -std=c++14 -Wsystem-headers -Wall -Wextra -c test.cpp
  In file included from test.cpp:1:
  In file included from /usr/include/c++/v1/string:470:
  /usr/include/c++/v1/string_view:763:29: warning: user-defined literal 
suffixes not starting with '_' are reserved [-Wuser-defined-literals]
      basic_string_view<char> operator "" sv(const char *__str, size_t __len)
                              ^
  /usr/include/c++/v1/string_view:769:32: warning: user-defined literal 
suffixes not starting with '_' are reserved [-Wuser-defined-literals]
      basic_string_view<wchar_t> operator "" sv(const wchar_t *__str, size_t 
__len)
                                 ^
  /usr/include/c++/v1/string_view:775:33: warning: user-defined literal 
suffixes not starting with '_' are reserved [-Wuser-defined-literals]
      basic_string_view<char16_t> operator "" sv(const char16_t *__str, size_t 
__len)
                                  ^
  /usr/include/c++/v1/string_view:781:33: warning: user-defined literal 
suffixes not starting with '_' are reserved [-Wuser-defined-literals]
      basic_string_view<char32_t> operator "" sv(const char32_t *__str, size_t 
__len)
                                  ^
  In file included from test.cpp:1:
  /usr/include/c++/v1/string:4012:24: warning: user-defined literal suffixes 
not starting with '_' are reserved [-Wuser-defined-literals]
      basic_string<char> operator "" s( const char *__str, size_t __len )
                         ^
  /usr/include/c++/v1/string:4018:27: warning: user-defined literal suffixes 
not starting with '_' are reserved [-Wuser-defined-literals]
      basic_string<wchar_t> operator "" s( const wchar_t *__str, size_t __len )
                            ^
  /usr/include/c++/v1/string:4024:28: warning: user-defined literal suffixes 
not starting with '_' are reserved [-Wuser-defined-literals]
      basic_string<char16_t> operator "" s( const char16_t *__str, size_t __len 
)
                             ^
  /usr/include/c++/v1/string:4030:28: warning: user-defined literal suffixes 
not starting with '_' are reserved [-Wuser-defined-literals]
      basic_string<char32_t> operator "" s( const char32_t *__str, size_t __len 
)
                             ^
  8 warnings generated.

Both @aaron.ballman and @mclow.lists felt that adding this workaround to
the libc++ headers was the wrong way, and it should be fixed in clang
instead.

Here is a proposal to do just that.  I verified that this suppresses the
warning, even when -Wsystem-headers is used, and that the warning is
still emitted for a declaration outside of system headers.


Repository:
  rC Clang

https://reviews.llvm.org/D41080

Files:
  lib/Sema/SemaDeclCXX.cpp


Index: lib/Sema/SemaDeclCXX.cpp
===================================================================
--- lib/Sema/SemaDeclCXX.cpp
+++ lib/Sema/SemaDeclCXX.cpp
@@ -13076,7 +13076,8 @@
 
   StringRef LiteralName
     = FnDecl->getDeclName().getCXXLiteralIdentifier()->getName();
-  if (LiteralName[0] != '_') {
+  if (LiteralName[0] != '_' &&
+      !getSourceManager().isInSystemHeader(FnDecl->getLocation())) {
     // C++11 [usrlit.suffix]p1:
     //   Literal suffix identifiers that do not start with an underscore
     //   are reserved for future standardization.


Index: lib/Sema/SemaDeclCXX.cpp
===================================================================
--- lib/Sema/SemaDeclCXX.cpp
+++ lib/Sema/SemaDeclCXX.cpp
@@ -13076,7 +13076,8 @@
 
   StringRef LiteralName
     = FnDecl->getDeclName().getCXXLiteralIdentifier()->getName();
-  if (LiteralName[0] != '_') {
+  if (LiteralName[0] != '_' &&
+      !getSourceManager().isInSystemHeader(FnDecl->getLocation())) {
     // C++11 [usrlit.suffix]p1:
     //   Literal suffix identifiers that do not start with an underscore
     //   are reserved for future standardization.
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to