From 3cf69bce69da1e21c23fda1b772a3c5e0643309f Mon Sep 17 00:00:00 2001 From: Erich Keane Date: Fri, 9 Jun 2017 22:50:02 +0000 Subject: Support operator keywords used in Windows SDK(fix ubsan) UBSan found an issue with a nullptr being assigned to a reference. This was because a following function went back and checked the identifier in the CPPOperatorName case. This patch corrects that location with the original logic as well. llvm-svn: 305128 --- clang/lib/Lex/Preprocessor.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'clang/lib/Lex/Preprocessor.cpp') diff --git a/clang/lib/Lex/Preprocessor.cpp b/clang/lib/Lex/Preprocessor.cpp index 77b46ae5ccc..f9a399cd7fd 100644 --- a/clang/lib/Lex/Preprocessor.cpp +++ b/clang/lib/Lex/Preprocessor.cpp @@ -713,7 +713,9 @@ bool Preprocessor::HandleIdentifier(Token &Identifier) { // C++ 2.11p2: If this is an alternative representation of a C++ operator, // then we act as if it is the actual operator and not the textual // representation of it. - if (II.isCPlusPlusOperatorKeyword()) + if (II.isCPlusPlusOperatorKeyword() && + !(getLangOpts().MSVCCompat && + getSourceManager().isInSystemHeader(Identifier.getLocation()))) Identifier.setIdentifierInfo(nullptr); // If this is an extension token, diagnose its use. -- cgit v1.2.3