]> granicus.if.org Git - clang/commitdiff
Support operator keywords used in Windows SDK(fix ubsan)
authorErich Keane <erich.keane@intel.com>
Fri, 9 Jun 2017 22:50:02 +0000 (22:50 +0000)
committerErich Keane <erich.keane@intel.com>
Fri, 9 Jun 2017 22:50:02 +0000 (22:50 +0000)
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.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@305128 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Lex/Preprocessor.cpp

index 77b46ae5cccb6644ae61fa1bf9b09eb7387772f4..f9a399cd7fd783b6b14c3cf824c8c73936c4d23b 100644 (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.