[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 06:53:15 PDT 2024


================
@@ -613,7 +613,7 @@ bool DarwinAsmParser::parseDirectiveLinkerOption(StringRef IDVal, SMLoc) {
       return TokError("expected string in '" + Twine(IDVal) + "' directive");
 
     std::string Data;
-    if (getParser().parseEscapedString(Data))
+    if (getParser().parseEscapedString(Data, false))
----------------
s-barannikov wrote:

I guess the intent of the warning is to help finding missing quotes in such pieces of assembly:

```asm
.string "asdf
// lots of directives / code here
.string "qwer"
```

The assembler would complain about unknown instruction mnemonic "qwer" because it parsed everything after the very first quote as an argument of the first `.string` directive. This consideration should apply to `.linker_option` directive as well, which is unlikely to expect newlines in the argument. That is, I would prohibit newlines in the argument of most, if not all, directives calling `parseEscapedString`.


https://github.com/llvm/llvm-project/pull/98060


More information about the llvm-commits mailing list