Author: arphaman Date: Tue Oct 10 17:41:20 2017 New Revision: 315398 URL: http://llvm.org/viewvc/llvm-project?rev=315398&view=rev Log: 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 Modified: cfe/trunk/lib/Lex/Lexer.cpp cfe/trunk/test/Parser/editor-placeholder-recovery.cpp Modified: cfe/trunk/lib/Lex/Lexer.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/Lexer.cpp?rev=315398&r1=315397&r2=315398&view=diff ============================================================================== --- cfe/trunk/lib/Lex/Lexer.cpp (original) +++ cfe/trunk/lib/Lex/Lexer.cpp Tue Oct 10 17:41:20 2017 @@ -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; Modified: cfe/trunk/test/Parser/editor-placeholder-recovery.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Parser/editor-placeholder-recovery.cpp?rev=315398&r1=315397&r2=315398&view=diff ============================================================================== --- cfe/trunk/test/Parser/editor-placeholder-recovery.cpp (original) +++ cfe/trunk/test/Parser/editor-placeholder-recovery.cpp Tue Oct 10 17:41:20 2017 @@ -69,3 +69,7 @@ void Struct::method(<#Struct &x#>, noSup // 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}} +} _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits