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

Richard Smith via cfe-commits cfe-commits at lists.llvm.org
Fri Nov 18 17:32:03 PST 2016


rsmith added inline comments.


================
Comment at: include/clang/Basic/DiagnosticLexKinds.td:189-190
   InGroup<CXXPre1zCompatPedantic>, DefaultIgnore;
+def err_cxx1z_string_view_literal : Error<
+  "string_view literals are a C++1z feature">;
 def ext_binary_literal : Extension<
----------------
I don't see a need for a custom diagnostic for this. Using our normal "reserved ud-suffix" diagnostic seems fine, and it doesn't make sense to treat this suffix as a hard error but accept all the rest with a warning.


================
Comment at: lib/Lex/LiteralSupport.cpp:1716-1717
+StringLiteralParser::UDSuffixResult
+StringLiteralParser::isValidUDSuffix(const LangOptions &LangOpts,
+                                     StringRef Suffix) {
+  if (!LangOpts.CPlusPlus11 || Suffix.empty())
----------------
Just make this call `NumericLiteralParser::isValidUDSuffix` and then check for the `sv` case. All the numeric suffixes are also valid string literal suffixes for the form `operator""suffix`.


https://reviews.llvm.org/D26829





More information about the cfe-commits mailing list