AntonBikineev updated this revision to Diff 78490.

https://reviews.llvm.org/D26829

Files:
  include/clang/Basic/DiagnosticLexKinds.td
  lib/Lex/Lexer.cpp


Index: lib/Lex/Lexer.cpp
===================================================================
--- lib/Lex/Lexer.cpp
+++ lib/Lex/Lexer.cpp
@@ -1713,6 +1713,13 @@
                                          getLangOpts());
         if (!isIdentifierBody(Next)) {
           // End of suffix. Check whether this is on the whitelist.
+          if (Chars == 2 && Buffer[0] == 's' && Buffer[1] == 'v') {
+            IsUDSuffix = true;
+            if (!getLangOpts().CPlusPlus1z)
+              Diag(CurPtr, diag::warn_cxx1z_string_view_literal)
+                << FixItHint::CreateInsertion(getSourceLocation(CurPtr), " ");
+            break;
+          }
           IsUDSuffix = (Chars == 1 && Buffer[0] == 's') ||
                        NumericLiteralParser::isValidUDSuffix(
                            getLangOpts(), StringRef(Buffer, Chars));
Index: include/clang/Basic/DiagnosticLexKinds.td
===================================================================
--- include/clang/Basic/DiagnosticLexKinds.td
+++ include/clang/Basic/DiagnosticLexKinds.td
@@ -186,6 +186,8 @@
   "hexadecimal floating literals are incompatible with "
   "C++ standards before C++1z">,
   InGroup<CXXPre1zCompatPedantic>, DefaultIgnore;
+def warn_cxx1z_string_view_literal : Warning<
+  "string_view literals are a C++1z feature">, InGroup<CXX1z>;
 def ext_binary_literal : Extension<
   "binary integer literals are a GNU extension">, InGroup<GNUBinaryLiteral>;
 def ext_binary_literal_cxx14 : Extension<


Index: lib/Lex/Lexer.cpp
===================================================================
--- lib/Lex/Lexer.cpp
+++ lib/Lex/Lexer.cpp
@@ -1713,6 +1713,13 @@
                                          getLangOpts());
         if (!isIdentifierBody(Next)) {
           // End of suffix. Check whether this is on the whitelist.
+          if (Chars == 2 && Buffer[0] == 's' && Buffer[1] == 'v') {
+            IsUDSuffix = true;
+            if (!getLangOpts().CPlusPlus1z)
+              Diag(CurPtr, diag::warn_cxx1z_string_view_literal)
+                << FixItHint::CreateInsertion(getSourceLocation(CurPtr), " ");
+            break;
+          }
           IsUDSuffix = (Chars == 1 && Buffer[0] == 's') ||
                        NumericLiteralParser::isValidUDSuffix(
                            getLangOpts(), StringRef(Buffer, Chars));
Index: include/clang/Basic/DiagnosticLexKinds.td
===================================================================
--- include/clang/Basic/DiagnosticLexKinds.td
+++ include/clang/Basic/DiagnosticLexKinds.td
@@ -186,6 +186,8 @@
   "hexadecimal floating literals are incompatible with "
   "C++ standards before C++1z">,
   InGroup<CXXPre1zCompatPedantic>, DefaultIgnore;
+def warn_cxx1z_string_view_literal : Warning<
+  "string_view literals are a C++1z feature">, InGroup<CXX1z>;
 def ext_binary_literal : Extension<
   "binary integer literals are a GNU extension">, InGroup<GNUBinaryLiteral>;
 def ext_binary_literal_cxx14 : Extension<
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to