[llvm] 8f386ff - [ms-inline asm] Add error check for `getAsInteger`
Phoebe Wang via llvm-commits
llvm-commits at lists.llvm.org
Mon May 29 20:21:08 PDT 2023
Author: Phoebe Wang
Date: 2023-05-30T11:20:57+08:00
New Revision: 8f386ff69ab8e012c1716ae05e70fd5288435835
URL: https://github.com/llvm/llvm-project/commit/8f386ff69ab8e012c1716ae05e70fd5288435835
DIFF: https://github.com/llvm/llvm-project/commit/8f386ff69ab8e012c1716ae05e70fd5288435835.diff
LOG: [ms-inline asm] Add error check for `getAsInteger`
.Imm can get lexed as a real, but a real doesn't equal to .Imm, e.g.,
2.5 or .123e+8. We should report error for it rather than silently ignore.
Reviewed By: skan
Differential Revision: https://reviews.llvm.org/D151652
Added:
Modified:
llvm/lib/Target/X86/AsmParser/X86AsmParser.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Target/X86/AsmParser/X86AsmParser.cpp b/llvm/lib/Target/X86/AsmParser/X86AsmParser.cpp
index 54d297bd58720..8c6ae1d1611aa 100644
--- a/llvm/lib/Target/X86/AsmParser/X86AsmParser.cpp
+++ b/llvm/lib/Target/X86/AsmParser/X86AsmParser.cpp
@@ -2315,7 +2315,8 @@ bool X86AsmParser::ParseIntelDotOperator(IntelExprStateMachine &SM,
// .Imm gets lexed as a real.
if (Tok.is(AsmToken::Real)) {
APInt DotDisp;
- DotDispStr.getAsInteger(10, DotDisp);
+ if (DotDispStr.getAsInteger(10, DotDisp))
+ return Error(Tok.getLoc(), "Unexpected offset");
Info.Offset = DotDisp.getZExtValue();
} else if ((isParsingMSInlineAsm() || getParser().isParsingMasm()) &&
Tok.is(AsmToken::Identifier)) {
More information about the llvm-commits
mailing list