summaryrefslogtreecommitdiffstats
path: root/llvm/tools/llvm-mc/AsmParser.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2009-07-16 06:14:39 +0000
committerChris Lattner <sabre@nondot.org>2009-07-16 06:14:39 +0000
commit693fbb8fee1ce39a8729587f910fc916a76ced23 (patch)
tree1e2f40e97054264d29019e11374f534db7284f35 /llvm/tools/llvm-mc/AsmParser.cpp
parent3afa3e1d918058af30c2dae3902d2852a4198d71 (diff)
downloadbcm5719-llvm-693fbb8fee1ce39a8729587f910fc916a76ced23.tar.gz
bcm5719-llvm-693fbb8fee1ce39a8729587f910fc916a76ced23.zip
implement .include in the lexer/parser instead of passing it into the streamer.
llvm-svn: 75896
Diffstat (limited to 'llvm/tools/llvm-mc/AsmParser.cpp')
-rw-r--r--llvm/tools/llvm-mc/AsmParser.cpp20
1 files changed, 13 insertions, 7 deletions
diff --git a/llvm/tools/llvm-mc/AsmParser.cpp b/llvm/tools/llvm-mc/AsmParser.cpp
index cb21a93bb1d..68eb9d56c07 100644
--- a/llvm/tools/llvm-mc/AsmParser.cpp
+++ b/llvm/tools/llvm-mc/AsmParser.cpp
@@ -1168,21 +1168,27 @@ bool AsmParser::ParseDirectiveDarwinLsym() {
/// ParseDirectiveInclude
/// ::= .include "filename"
bool AsmParser::ParseDirectiveInclude() {
- const char *Str;
-
if (Lexer.isNot(asmtok::String))
return TokError("expected string in '.include' directive");
- Str = Lexer.getCurStrVal();
-
+ std::string Filename = Lexer.getCurStrVal();
+ SMLoc IncludeLoc = Lexer.getLoc();
Lexer.Lex();
if (Lexer.isNot(asmtok::EndOfStatement))
return TokError("unexpected token in '.include' directive");
- Lexer.Lex();
-
- Out.SwitchInputAssemblyFile(Str);
+ // Strip the quotes.
+ Filename = Filename.substr(1, Filename.size()-2);
+
+ // Attempt to switch the lexer to the included file before consuming the end
+ // of statement to avoid losing it when we switch.
+ if (Lexer.EnterIncludeFile(Filename)) {
+ Lexer.PrintMessage(IncludeLoc,
+ "Could not find include file '" + Filename + "'",
+ "error");
+ return true;
+ }
return false;
}
OpenPOWER on IntegriCloud