diff options
author | Chad Rosier <mcrosier@apple.com> | 2013-04-11 23:24:15 +0000 |
---|---|---|
committer | Chad Rosier <mcrosier@apple.com> | 2013-04-11 23:24:15 +0000 |
commit | adb5c16aa74d67b6c36b4c22dc0fc2cdecc43acb (patch) | |
tree | a1737b88072e307e0ba3bf62290f44f47579fe99 /lib/Target/X86/AsmParser/X86AsmParser.cpp | |
parent | 327f0100d1c1aa738d13b45d70eab08d0d2030fb (diff) |
[ms-inline asm] Pass a StringRef reference to ParseIntelVarWithQualifier so we
can build up the identifier string. No test case as support for looking up
these type of identifiers hasn't been implemented on the clang side.
Part of rdar://13499009
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@179336 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Target/X86/AsmParser/X86AsmParser.cpp')
-rw-r--r-- | lib/Target/X86/AsmParser/X86AsmParser.cpp | 30 |
1 files changed, 15 insertions, 15 deletions
diff --git a/lib/Target/X86/AsmParser/X86AsmParser.cpp b/lib/Target/X86/AsmParser/X86AsmParser.cpp index aaf571ae9d..6f026cd379 100644 --- a/lib/Target/X86/AsmParser/X86AsmParser.cpp +++ b/lib/Target/X86/AsmParser/X86AsmParser.cpp @@ -64,7 +64,7 @@ private: X86Operand *ParseIntelBracExpression(unsigned SegReg, SMLoc SizeDirLoc, uint64_t ImmDisp, unsigned Size); X86Operand *ParseIntelVarWithQualifier(const MCExpr *&Disp, - SMLoc &IdentStart); + StringRef &Identifier); X86Operand *ParseMemOperand(unsigned SegReg, SMLoc StartLoc); X86Operand *CreateMemForInlineAsm(const MCExpr *Disp, SMLoc Start, SMLoc End, @@ -1130,11 +1130,11 @@ X86Operand *X86AsmParser::ParseIntelBracExpression(unsigned SegReg, SMLoc Loc = Tok.getLoc(); if (ParseRegister(TmpReg, Loc, End)) { const MCExpr *Disp; - SMLoc IdentStart = Tok.getLoc(); + StringRef Identifier = Tok.getString(); if (getParser().parseExpression(Disp, End)) return 0; - if (X86Operand *Err = ParseIntelVarWithQualifier(Disp, IdentStart)) + if (X86Operand *Err = ParseIntelVarWithQualifier(Disp, Identifier)) return Err; if (getLexer().isNot(AsmToken::RBrac)) @@ -1145,12 +1145,11 @@ X86Operand *X86AsmParser::ParseIntelBracExpression(unsigned SegReg, InstInfo->AsmRewrites->push_back(AsmRewrite(AOK_Skip, Start, 1)); InstInfo->AsmRewrites->push_back(AsmRewrite(AOK_Skip, Tok.getLoc(), 1)); } - unsigned Len = Tok.getLoc().getPointer() - IdentStart.getPointer(); - StringRef SymName(IdentStart.getPointer(), Len); Parser.Lex(); // Eat ']' if (!isParsingInlineAsm()) - return X86Operand::CreateMem(Disp, Start, End, Size, SymName); - return CreateMemForInlineAsm(Disp, Start, End, SizeDirLoc, Size, SymName); + return X86Operand::CreateMem(Disp, Start, End, Size); + return CreateMemForInlineAsm(Disp, Start, End, SizeDirLoc, Size, + Identifier); } } @@ -1255,7 +1254,7 @@ X86Operand *X86AsmParser::ParseIntelBracExpression(unsigned SegReg, // Inline assembly may use variable names with namespace alias qualifiers. X86Operand *X86AsmParser::ParseIntelVarWithQualifier(const MCExpr *&Disp, - SMLoc &IdentStart) { + StringRef &Identifier) { // We should only see Foo::Bar if we're parsing inline assembly. if (!isParsingInlineAsm()) return 0; @@ -1266,6 +1265,7 @@ X86Operand *X86AsmParser::ParseIntelVarWithQualifier(const MCExpr *&Disp, bool Done = false; const AsmToken &Tok = Parser.getTok(); + AsmToken IdentEnd = Tok; while (!Done) { switch (getLexer().getKind()) { default: @@ -1280,12 +1280,14 @@ X86Operand *X86AsmParser::ParseIntelVarWithQualifier(const MCExpr *&Disp, return ErrorOperand(Tok.getLoc(), "Expected an identifier token!"); break; case AsmToken::Identifier: + IdentEnd = Tok; getLexer().Lex(); // Consume the identifier. break; } } - size_t Len = Tok.getLoc().getPointer() - IdentStart.getPointer(); - StringRef Identifier(IdentStart.getPointer(), Len); + + unsigned Len = IdentEnd.getLoc().getPointer() - Identifier.data(); + Identifier = StringRef(Identifier.data(), Len + IdentEnd.getString().size()); MCSymbol *Sym = getContext().GetOrCreateSymbol(Identifier); MCSymbolRefExpr::VariantKind Variant = MCSymbolRefExpr::VK_None; Disp = MCSymbolRefExpr::Create(Sym, Variant, getParser().getContext()); @@ -1333,19 +1335,17 @@ X86Operand *X86AsmParser::ParseIntelMemOperand(unsigned SegReg, } const MCExpr *Disp = 0; - SMLoc IdentStart = Tok.getLoc(); + StringRef Identifier = Tok.getString(); if (getParser().parseExpression(Disp, End)) return 0; if (!isParsingInlineAsm()) return X86Operand::CreateMem(Disp, Start, End, Size); - if (X86Operand *Err = ParseIntelVarWithQualifier(Disp, IdentStart)) + if (X86Operand *Err = ParseIntelVarWithQualifier(Disp, Identifier)) return Err; - unsigned Len = Tok.getLoc().getPointer() - IdentStart.getPointer(); - StringRef SymName(IdentStart.getPointer(), Len); - return CreateMemForInlineAsm(Disp, Start, End, Start, Size, SymName); + return CreateMemForInlineAsm(Disp, Start, End, Start, Size, Identifier); } /// Parse the '.' operator. |