[llvm] [MC,ELF] Emit warning if a string constant contains newline char. (PR #98060)
Sergei Barannikov via llvm-commits
llvm-commits at lists.llvm.org
Tue Jul 9 03:38:44 PDT 2024
================
@@ -3125,6 +3125,16 @@ bool AsmParser::parseDirectiveAscii(StringRef IDVal, bool ZeroTerminated) {
do {
if (parseEscapedString(Data))
return true;
+
+ // Warn about newline characters in parsed string like GAS.
+ size_t NewlinePos = -1;
+ size_t DataSize = Data.size();
+ const char *Start = getTok().getLoc().getPointer() - DataSize - 1;
----------------
s-barannikov wrote:
The location will be incorrect if the string contains escaped characters (e.g. '\xFF'), and I don't see a way how you can reliably get the location of a newline without making `parseEscapedString` return it. Moreover, the string could contain '\n', which must not be diagnosed.
https://github.com/llvm/llvm-project/pull/98060
More information about the llvm-commits
mailing list