Lex: Fix quadratic behavior when unescaping _Pragma strings.

No functionality change.

llvm-svn: 181114
This commit is contained in:
Benjamin Kramer 2013-05-04 10:37:20 +00:00
parent acb8ecd664
commit c2f5f29b8d
1 changed files with 6 additions and 5 deletions

View File

@ -254,14 +254,15 @@ void Preprocessor::Handle_Pragma(Token &Tok) {
"Invalid string token!");
// Remove escaped quotes and escapes.
for (unsigned i = 1, e = StrVal.size(); i < e-2; ++i) {
if (StrVal[i] == '\\' &&
(StrVal[i+1] == '\\' || StrVal[i+1] == '"')) {
unsigned ResultPos = 1;
for (unsigned i = 1, e = StrVal.size() - 2; i != e; ++i) {
if (StrVal[i] != '\\' ||
(StrVal[i + 1] != '\\' && StrVal[i + 1] != '"')) {
// \\ -> '\' and \" -> '"'.
StrVal.erase(StrVal.begin()+i);
--e;
StrVal[ResultPos++] = StrVal[i];
}
}
StrVal.erase(StrVal.begin() + ResultPos, StrVal.end() - 2);
}
// Remove the front quote, replacing it with a space, so that the pragma