r305128 - Support operator keywords used in Windows SDK(fix ubsan)

Erich Keane via cfe-commits cfe-commits at lists.llvm.org
Fri Jun 9 15:50:02 PDT 2017


Author: erichkeane
Date: Fri Jun  9 17:50:02 2017
New Revision: 305128

URL: http://llvm.org/viewvc/llvm-project?rev=305128&view=rev
Log:
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.

Modified:
    cfe/trunk/lib/Lex/Preprocessor.cpp

Modified: cfe/trunk/lib/Lex/Preprocessor.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/Preprocessor.cpp?rev=305128&r1=305127&r2=305128&view=diff
==============================================================================
--- cfe/trunk/lib/Lex/Preprocessor.cpp (original)
+++ cfe/trunk/lib/Lex/Preprocessor.cpp Fri Jun  9 17:50:02 2017
@@ -713,7 +713,9 @@ bool Preprocessor::HandleIdentifier(Toke
   // 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.




More information about the cfe-commits mailing list