A '<' with a trigraph '#' is not a valid editor placeholder

Credit to OSS-Fuzz for discovery:
https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=3137#c5

rdar://34923985

llvm-svn: 315398
This commit is contained in:
Alex Lorenz 2017-10-11 00:41:20 +00:00
parent 18057cb34c
commit c1e32fca96
2 changed files with 6 additions and 1 deletions

View File

@ -3542,7 +3542,8 @@ LexNextToken:
} else if (LangOpts.Digraphs && Char == '%') { // '<%' -> '{'
CurPtr = ConsumeChar(CurPtr, SizeTmp, Result);
Kind = tok::l_brace;
} else if (Char == '#' && lexEditorPlaceholder(Result, CurPtr)) {
} else if (Char == '#' && /*Not a trigraph*/ SizeTmp == 1 &&
lexEditorPlaceholder(Result, CurPtr)) {
return true;
} else {
Kind = tok::less;

View File

@ -69,3 +69,7 @@ void Struct::method(<#Struct &x#>, noSupressionHere) { // expected-error {{unkno
// expected-error@-2 {{editor placeholder in source file}}
#endif
}
void handleTrigraph() {
<??=placeholder#> // expected-error {{expected expression}} expected-error {{expected expression}} expected-warning {{trigraph converted to '#' character}}
}