[llvm-commits] [llvm] r132028 - in /llvm/trunk: lib/MC/MCParser/COFFAsmParser.cpp test/MC/AsmParser/directive_seh.s
Charles Davis
cdavis at mines.edu
Tue May 24 18:33:42 PDT 2011
Author: cdavis
Date: Tue May 24 20:33:42 2011
New Revision: 132028
URL: http://llvm.org/viewvc/llvm-project?rev=132028&view=rev
Log:
Add a test for the .seh_handler directive. Fix problems with the parsing
method exposed by the test. While we're at it, simplify the .seh_proc
parsing method.
Modified:
llvm/trunk/lib/MC/MCParser/COFFAsmParser.cpp
llvm/trunk/test/MC/AsmParser/directive_seh.s
Modified: llvm/trunk/lib/MC/MCParser/COFFAsmParser.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCParser/COFFAsmParser.cpp?rev=132028&r1=132027&r2=132028&view=diff
==============================================================================
--- llvm/trunk/lib/MC/MCParser/COFFAsmParser.cpp (original)
+++ llvm/trunk/lib/MC/MCParser/COFFAsmParser.cpp Tue May 24 20:33:42 2011
@@ -184,20 +184,17 @@
}
bool COFFAsmParser::ParseSEHDirectiveStartProc(StringRef, SMLoc) {
- const MCExpr *e;
- const MCSymbolRefExpr *funcExpr;
- SMLoc startLoc = getLexer().getLoc();
- if (getParser().ParseExpression(e))
+ StringRef SymbolID;
+ if (getParser().ParseIdentifier(SymbolID))
return true;
- if (!(funcExpr = dyn_cast<MCSymbolRefExpr>(e)))
- return Error(startLoc, "expected symbol");
-
if (getLexer().isNot(AsmToken::EndOfStatement))
return TokError("unexpected token in directive");
+ MCSymbol *Symbol = getContext().GetOrCreateSymbol(SymbolID);
+
Lex();
- getStreamer().EmitWin64EHStartProc(&funcExpr->getSymbol());
+ getStreamer().EmitWin64EHStartProc(Symbol);
return false;
}
@@ -220,29 +217,28 @@
}
bool COFFAsmParser::ParseSEHDirectiveHandler(StringRef, SMLoc) {
- const MCExpr *e;
- const MCSymbolRefExpr *funcExpr;
- SMLoc startLoc = getLexer().getLoc();
- if (getParser().ParseExpression(e))
+ StringRef SymbolID;
+ if (getParser().ParseIdentifier(SymbolID))
return true;
- if (!(funcExpr = dyn_cast<MCSymbolRefExpr>(e)))
- return Error(startLoc, "expected symbol");
-
+ if (getLexer().isNot(AsmToken::Comma))
+ return TokError("you must specify one or both of @unwind or @except");
+ Lex();
bool unwind = false, except = false;
- startLoc = getLexer().getLoc();
- if (!ParseAtUnwindOrAtExcept(unwind, except))
- return Error(startLoc,"you must specify one or both of @unwind or @except");
+ if (ParseAtUnwindOrAtExcept(unwind, except))
+ return true;
if (getLexer().is(AsmToken::Comma)) {
Lex();
- if (!ParseAtUnwindOrAtExcept(unwind, except))
+ if (ParseAtUnwindOrAtExcept(unwind, except))
return true;
}
if (getLexer().isNot(AsmToken::EndOfStatement))
return TokError("unexpected token in directive");
+ MCSymbol *handler = getContext().GetOrCreateSymbol(SymbolID);
+
Lex();
- getStreamer().EmitWin64EHHandler(&funcExpr->getSymbol(), unwind, except);
+ getStreamer().EmitWin64EHHandler(handler, unwind, except);
return false;
}
@@ -372,12 +368,15 @@
bool COFFAsmParser::ParseAtUnwindOrAtExcept(bool &unwind, bool &except) {
StringRef identifier;
+ if (getLexer().isNot(AsmToken::At))
+ return TokError("a handler attribute must begin with '@'");
SMLoc startLoc = getLexer().getLoc();
- if (!getParser().ParseIdentifier(identifier))
+ Lex();
+ if (getParser().ParseIdentifier(identifier))
return Error(startLoc, "expected @unwind or @except");
- if (identifier == "@unwind")
+ if (identifier == "unwind")
unwind = true;
- else if (identifier == "@except")
+ else if (identifier == "except")
except = true;
else
return Error(startLoc, "expected @unwind or @except");
Modified: llvm/trunk/test/MC/AsmParser/directive_seh.s
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/AsmParser/directive_seh.s?rev=132028&r1=132027&r2=132028&view=diff
==============================================================================
--- llvm/trunk/test/MC/AsmParser/directive_seh.s (original)
+++ llvm/trunk/test/MC/AsmParser/directive_seh.s Tue May 24 20:33:42 2011
@@ -1,8 +1,9 @@
# RUN: llvm-mc -triple x86_64-pc-win32 %s | FileCheck %s
# CHECK: .seh_proc func
-# CHECK: .seh_stackalloc 8
+# CHECK: .seh_stackalloc 24
# CHECK: .seh_endprologue
+# CHECK: .seh_handler __C_specific_handler, @except
# CHECK: .seh_endproc
.text
@@ -10,9 +11,10 @@
.def func; .scl 2; .type 32; .endef
.seh_proc func
func:
- subq $8, %rsp
- .seh_stackalloc 8
+ subq $24, %rsp
+ .seh_stackalloc 24
.seh_endprologue
- addq $8, %rsp
+ .seh_handler __C_specific_handler, @except
+ addq $24, %rsp
ret
.seh_endproc
More information about the llvm-commits
mailing list