[llvm] [X86] Invalid assembly given inverted meaning (PR #190460)

via llvm-commits llvm-commits at lists.llvm.org
Sat Apr 4 06:31:31 PDT 2026


github-actions[bot] wrote:

<!--LLVM CODE FORMAT COMMENT: {clang-format}-->


:warning: C/C++ code formatter, clang-format found issues in your code. :warning:

<details>
<summary>
You can test this locally with the following command:
</summary>

``````````bash
git-clang-format --diff origin/main HEAD --extensions cpp -- llvm/lib/Target/X86/AsmParser/X86AsmParser.cpp --diff_from_common_commit
``````````

:warning:
The reproduction instructions above might return results for more than one PR
in a stack if you are using a stacked PR workflow. You can limit the results by
changing `origin/main` to the base branch/commit you want to compare against.
:warning:

</details>

<details>
<summary>
View the diff from clang-format here.
</summary>

``````````diff
diff --git a/llvm/lib/Target/X86/AsmParser/X86AsmParser.cpp b/llvm/lib/Target/X86/AsmParser/X86AsmParser.cpp
index 4a1b899e4..5fe167967 100644
--- a/llvm/lib/Target/X86/AsmParser/X86AsmParser.cpp
+++ b/llvm/lib/Target/X86/AsmParser/X86AsmParser.cpp
@@ -506,7 +506,8 @@ private:
     void setPIC() { IsPIC = true; }
 
     bool hadError() const { return State == IES_ERROR; }
-    SMLoc getLocForNegativeScaleError(StringRef ErrMsg, SMLoc DefaultLoc) const {
+    SMLoc getLocForNegativeScaleError(StringRef ErrMsg,
+                                      SMLoc DefaultLoc) const {
       return ErrMsg == "scale factor in address cannot be negative"
                  ? NegativeAdditiveTermLoc
                  : DefaultLoc;
@@ -752,13 +753,12 @@ private:
         State = IES_MINUS;
         // push minus operator if it is not a negate operator
         if (CurrState == IES_REGISTER || CurrState == IES_RPAREN ||
-            CurrState == IES_INTEGER  || CurrState == IES_RBRAC  ||
+            CurrState == IES_INTEGER || CurrState == IES_RBRAC ||
             CurrState == IES_OFFSET) {
           IC.pushOperator(IC_MINUS);
           NegativeAdditiveTerm = true;
           NegativeAdditiveTermLoc = MinusLoc;
-        }
-        else if (PrevState == IES_REGISTER && CurrState == IES_MULTIPLY) {
+        } else if (PrevState == IES_REGISTER && CurrState == IES_MULTIPLY) {
           // We have negate operator for Scale: it's illegal
           ErrMsg = "Scale can't be negative";
           return true;
@@ -2167,8 +2167,7 @@ bool X86AsmParser::ParseIntelExpression(IntelExprStateMachine &SM, SMLoc &End) {
         return Error(Tok.getLoc(), "Unexpected identifier!");
       } else if (SM.onIdentifierExpr(Val, Identifier, Info, FieldInfo.Type,
                                      false, ErrMsg)) {
-        return Error(SM.getLocForNegativeScaleError(ErrMsg, IdentLoc),
-                     ErrMsg);
+        return Error(SM.getLocForNegativeScaleError(ErrMsg, IdentLoc), ErrMsg);
       }
       break;
     }
@@ -2193,18 +2192,15 @@ bool X86AsmParser::ParseIntelExpression(IntelExprStateMachine &SM, SMLoc &End) {
           AsmTypeInfo Type;
           if (SM.onIdentifierExpr(Val, Identifier, Info, Type,
                                   isParsingMSInlineAsm(), ErrMsg))
-            return Error(SM.getLocForNegativeScaleError(ErrMsg, Loc),
-                         ErrMsg);
+            return Error(SM.getLocForNegativeScaleError(ErrMsg, Loc), ErrMsg);
           End = consumeToken();
         } else {
           if (SM.onInteger(IntVal, ErrMsg))
-            return Error(SM.getLocForNegativeScaleError(ErrMsg, Loc),
-                         ErrMsg);
+            return Error(SM.getLocForNegativeScaleError(ErrMsg, Loc), ErrMsg);
         }
       } else {
         if (SM.onInteger(IntVal, ErrMsg))
-          return Error(SM.getLocForNegativeScaleError(ErrMsg, Loc),
-                       ErrMsg);
+          return Error(SM.getLocForNegativeScaleError(ErrMsg, Loc), ErrMsg);
       }
       break;
     }

``````````

</details>


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


More information about the llvm-commits mailing list