[llvm] [MC,ELF] Use loc from the directive for `.abort` (PR #99648)

Sergei Barannikov via llvm-commits llvm-commits at lists.llvm.org
Fri Jul 19 06:37:32 PDT 2024


================
@@ -5095,18 +5095,16 @@ bool AsmParser::parseDirectiveComm(bool IsLocal) {
 
 /// parseDirectiveAbort
 ///  ::= .abort [... message ...]
-bool AsmParser::parseDirectiveAbort() {
-  // FIXME: Use loc from directive.
-  SMLoc Loc = getLexer().getLoc();
-
+bool AsmParser::parseDirectiveAbort(SMLoc DirectiveLoc) {
   StringRef Str = parseStringToEndOfStatement();
   if (parseEOL())
     return true;
 
   if (Str.empty())
-    return Error(Loc, ".abort detected. Assembly stopping.");
+    return Error(DirectiveLoc, ".abort detected. Assembly stopping.");
   else
-    return Error(Loc, ".abort '" + Str + "' detected. Assembly stopping.");
+    return Error(DirectiveLoc,
----------------
s-barannikov wrote:

While here, can you remove the `else`? https://llvm.org/docs/CodingStandards.html#don-t-use-else-after-a-return

The `return` below is unreachable, please remove it.


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


More information about the llvm-commits mailing list