summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlex Lorenz <arphaman@gmail.com>2017-10-11 00:41:20 +0000
committerAlex Lorenz <arphaman@gmail.com>2017-10-11 00:41:20 +0000
commitbd279d876518592ad5ddf5c9aee15bef8d551f0c (patch)
treef4936d1b485f1ced7a7a944fe84dc0d75284c6a6
parent4da3addc80e3d74bd6b174c7160f6151335bfc15 (diff)
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 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@315398 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--lib/Lex/Lexer.cpp3
-rw-r--r--test/Parser/editor-placeholder-recovery.cpp4
2 files changed, 6 insertions, 1 deletions
diff --git a/lib/Lex/Lexer.cpp b/lib/Lex/Lexer.cpp
index 9885ab9d3e..0c179c0fb8 100644
--- a/lib/Lex/Lexer.cpp
+++ b/lib/Lex/Lexer.cpp
@@ -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;
diff --git a/test/Parser/editor-placeholder-recovery.cpp b/test/Parser/editor-placeholder-recovery.cpp
index 48c290ee9a..d68e087d6f 100644
--- a/test/Parser/editor-placeholder-recovery.cpp
+++ b/test/Parser/editor-placeholder-recovery.cpp
@@ -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}}
+}