vsapsai added a comment.

On the first glance string erase and insert seem to be done correctly. But we 
can still improve the tests. Can you please add tests for tricky cases where 
new line or backslash appear in unexpected places? Some of the examples are

  R"ab\
  cd"
  
  R"ab
  
  c"
  
  R"ab
  \"
  
  R"ab
  \\"

I didn't check if all of them are valid but I hope you got the idea.



================
Comment at: lib/Lex/Lexer.cpp:223
+      ++e;
+    } else if (auto Size = getEscapedNewLineSize(Result.substr(i).data())) {
+      Result.erase(Result.begin() + i, Result.begin() + i + Size);
----------------
`getEscapedNewLineSize` mentions
> P[-1] is known to be a "\" or a trigraph equivalent on entry to this function.
Is this precondition correct in this case?

And `std::string::substr` creates a copy of a substring. It is inefficient in 
the loop and looks like you don't really need `std::string` here anyway.


https://reviews.llvm.org/D39279



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

Reply via email to