Author: sanwou01 Date: Fri Apr 7 05:13:00 2017 New Revision: 299754 URL: http://llvm.org/viewvc/llvm-project?rev=299754&view=rev Log: Skip Unicode character expansion in assembly files
Summary: When using the C preprocessor with assembly files, either with a capital `S` file extension, or with `-xassembler-with-cpp`, the Unicode escape sequence `\u` is ignored. The `\u` pattern can be used for expanding a macro argument that starts with `u`. Author: Salman Arif <salman.a...@arm.com> Reviewers: rengolin, olista01 Reviewed By: olista01 Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D31765 Added: cfe/trunk/test/Lexer/asm-preproc-no-unicode.s Modified: cfe/trunk/lib/Lex/Lexer.cpp Modified: cfe/trunk/lib/Lex/Lexer.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/Lexer.cpp?rev=299754&r1=299753&r2=299754&view=diff ============================================================================== --- cfe/trunk/lib/Lex/Lexer.cpp (original) +++ cfe/trunk/lib/Lex/Lexer.cpp Fri Apr 7 05:13:00 2017 @@ -3603,17 +3603,19 @@ LexNextToken: // UCNs (C99 6.4.3, C++11 [lex.charset]p2) case '\\': - if (uint32_t CodePoint = tryReadUCN(CurPtr, BufferPtr, &Result)) { - if (CheckUnicodeWhitespace(Result, CodePoint, CurPtr)) { - if (SkipWhitespace(Result, CurPtr, TokAtPhysicalStartOfLine)) - return true; // KeepWhitespaceMode + if (!LangOpts.AsmPreprocessor) { + if (uint32_t CodePoint = tryReadUCN(CurPtr, BufferPtr, &Result)) { + if (CheckUnicodeWhitespace(Result, CodePoint, CurPtr)) { + if (SkipWhitespace(Result, CurPtr, TokAtPhysicalStartOfLine)) + return true; // KeepWhitespaceMode - // We only saw whitespace, so just try again with this lexer. - // (We manually eliminate the tail call to avoid recursion.) - goto LexNextToken; - } + // We only saw whitespace, so just try again with this lexer. + // (We manually eliminate the tail call to avoid recursion.) + goto LexNextToken; + } - return LexUnicode(Result, CodePoint, CurPtr); + return LexUnicode(Result, CodePoint, CurPtr); + } } Kind = tok::unknown; Added: cfe/trunk/test/Lexer/asm-preproc-no-unicode.s URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Lexer/asm-preproc-no-unicode.s?rev=299754&view=auto ============================================================================== --- cfe/trunk/test/Lexer/asm-preproc-no-unicode.s (added) +++ cfe/trunk/test/Lexer/asm-preproc-no-unicode.s Fri Apr 7 05:13:00 2017 @@ -0,0 +1,8 @@ +// RUN: %clang -E -xassembler-with-cpp %s -o - 2>&1 | FileCheck %s + +// CHECK-NOT: warning: \u used with no following hex digits +// CHECK: .word \u + + .macro foo, u + .word \u + .endm _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits