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
This commit is contained in:
Erich Keane 2017-06-09 22:50:02 +00:00
parent 21fde385fa
commit 3cf69bce69
1 changed files with 3 additions and 1 deletions

View File

@ -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.