aboutsummaryrefslogtreecommitdiff
path: root/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
commit8e25e2d801bb1119cea080c7c860adcfbf85d65d (patch)
tree0dd48770cc0b11e59fc5e5d79994070c76e82a90 /tools/llvm-mc/AsmParser.cpp
parentc2b443a698493d3f2fe6ce2d8e7798a659eb3aae (diff)
implement .include in the lexer/parser instead of passing it into the streamer.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@75896 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'tools/llvm-mc/AsmParser.cpp')
-rw-r--r--tools/llvm-mc/AsmParser.cpp20
1 files changed, 13 insertions, 7 deletions
diff --git a/tools/llvm-mc/AsmParser.cpp b/tools/llvm-mc/AsmParser.cpp
index cb21a93bb1..68eb9d56c0 100644
--- a/tools/llvm-mc/AsmParser.cpp
+++ b/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;
}