Skip to content

Commit 2715c4d

Browse files
cor3ntinAaronBallman
authored andcommitted
Do not emit diagnostics for invalid unicode characters in preprocessing mode
This amends 4e80636 with a fix for https://lab.llvm.org/buildbot/#/builders/139/builds/8943
1 parent 7338be0 commit 2715c4d

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

clang/lib/Lex/Lexer.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1652,7 +1652,8 @@ bool Lexer::tryConsumeIdentifierUCN(const char *&CurPtr, unsigned Size,
16521652
if (!isAllowedIDChar(CodePoint, LangOpts)) {
16531653
if (isASCII(CodePoint) || isUnicodeWhitespace(CodePoint))
16541654
return false;
1655-
if (!isLexingRawMode())
1655+
if (!isLexingRawMode() && !ParsingPreprocessorDirective &&
1656+
!PP->isPreprocessedOutput())
16561657
diagnoseInvalidUnicodeCodepointInIdentifier(
16571658
PP->getDiagnostics(), LangOpts, CodePoint,
16581659
makeCharRange(*this, CurPtr, UCNPtr),
@@ -1691,7 +1692,8 @@ bool Lexer::tryConsumeIdentifierUTF8Char(const char *&CurPtr) {
16911692
if (isASCII(CodePoint) || isUnicodeWhitespace(CodePoint))
16921693
return false;
16931694

1694-
if (!isLexingRawMode())
1695+
if (!isLexingRawMode() && !ParsingPreprocessorDirective &&
1696+
!PP->isPreprocessedOutput())
16951697
diagnoseInvalidUnicodeCodepointInIdentifier(
16961698
PP->getDiagnostics(), LangOpts, CodePoint,
16971699
makeCharRange(*this, CurPtr, UnicodePtr), /*IsFirst=*/false);

clang/test/Lexer/unicode.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// RUN: %clang_cc1 -fsyntax-only -verify -x c -std=c11 %s
22
// RUN: %clang_cc1 -fsyntax-only -verify -x c++ -std=c++11 %s
3-
// RUN: %clang_cc1 -E -DPP_ONLY=1 %s -o %t
4-
// RUN: FileCheck --strict-whitespace --input-file=%t %s
3+
// RUN: %clang_cc1 -triple x86_64-scei-ps4 -E -DPP_ONLY=1 %s | FileCheck %s --strict-whitespace
4+
// RUN: %clang_cc1 -E -DPP_ONLY=1 %s | FileCheck %s --strict-whitespace
55

66
// This file contains Unicode characters; please do not "fix" them!
77

0 commit comments

Comments
 (0)