diff options
author | Yunzhong Gao <Yunzhong_Gao@playstation.sony.com> | 2013-09-05 19:14:26 +0000 |
---|---|---|
committer | Yunzhong Gao <Yunzhong_Gao@playstation.sony.com> | 2013-09-05 19:14:26 +0000 |
commit | 8c0f5067ccf1f5e12530b876b11010518fcc8274 (patch) | |
tree | 48b5de3e23394a28b66d692f54d13059d7c19db2 /llvm/lib/MC/MCParser/AsmParser.cpp | |
parent | a8a15ed22ac850bd13cd5f4bd3174c57899d2d6e (diff) | |
download | bcm5719-llvm-8c0f5067ccf1f5e12530b876b11010518fcc8274.tar.gz bcm5719-llvm-8c0f5067ccf1f5e12530b876b11010518fcc8274.zip |
Improve handling of .file, .include and .incbin directives to
allow escaped octal character sequences.
The patch was discussed in Phabricator. See:
http://llvm-reviews.chandlerc.com/D1289
llvm-svn: 190089
Diffstat (limited to 'llvm/lib/MC/MCParser/AsmParser.cpp')
-rw-r--r-- | llvm/lib/MC/MCParser/AsmParser.cpp | 28 |
1 files changed, 16 insertions, 12 deletions
diff --git a/llvm/lib/MC/MCParser/AsmParser.cpp b/llvm/lib/MC/MCParser/AsmParser.cpp index 31a09a967c6..ae88a3ee73c 100644 --- a/llvm/lib/MC/MCParser/AsmParser.cpp +++ b/llvm/lib/MC/MCParser/AsmParser.cpp @@ -2550,17 +2550,21 @@ bool AsmParser::ParseDirectiveFile(SMLoc DirectiveLoc) { return TokError("unexpected token in '.file' directive"); // Usually the directory and filename together, otherwise just the directory. - StringRef Path = getTok().getString(); - Path = Path.substr(1, Path.size()-2); + // Allow the strings to have escaped octal character sequence. + std::string Path = getTok().getString(); + if (parseEscapedString(Path)) + return true; Lex(); StringRef Directory; StringRef Filename; + std::string FilenameData; if (getLexer().is(AsmToken::String)) { if (FileNumber == -1) return TokError("explicit path specified, but no file number"); - Filename = getTok().getString(); - Filename = Filename.substr(1, Filename.size()-2); + if (parseEscapedString(FilenameData)) + return true; + Filename = FilenameData; Directory = Path; Lex(); } else { @@ -3496,16 +3500,16 @@ bool AsmParser::ParseDirectiveInclude() { if (getLexer().isNot(AsmToken::String)) return TokError("expected string in '.include' directive"); - std::string Filename = getTok().getString(); + // Allow the strings to have escaped octal character sequence. + std::string Filename; + if (parseEscapedString(Filename)) + return true; SMLoc IncludeLoc = getLexer().getLoc(); Lex(); if (getLexer().isNot(AsmToken::EndOfStatement)) return TokError("unexpected token in '.include' directive"); - // 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 (EnterIncludeFile(Filename)) { @@ -3522,16 +3526,16 @@ bool AsmParser::ParseDirectiveIncbin() { if (getLexer().isNot(AsmToken::String)) return TokError("expected string in '.incbin' directive"); - std::string Filename = getTok().getString(); + // Allow the strings to have escaped octal character sequence. + std::string Filename; + if (parseEscapedString(Filename)) + return true; SMLoc IncbinLoc = getLexer().getLoc(); Lex(); if (getLexer().isNot(AsmToken::EndOfStatement)) return TokError("unexpected token in '.incbin' directive"); - // Strip the quotes. - Filename = Filename.substr(1, Filename.size()-2); - // Attempt to process the included file. if (ProcessIncbinFile(Filename)) { Error(IncbinLoc, "Could not find incbin file '" + Filename + "'"); |