From 33c3d8a916cfe6cdef165a198735a49560c03652 Mon Sep 17 00:00:00 2001 From: Erich Keane Date: Fri, 9 Jun 2017 16:29:35 +0000 Subject: support operator keywords used in Windows SDK to support operator keywords used in Windows SDK, alter token type when seen in system headers Hello, I submitted D33505 to address this problem, but the proposal was rejected as too big a hammer. This change will allow clang to parse the WindowsSDK header which uses the operator name "or" as a field name. Treat cpp operator keywords as ordinary identifiers inside the Microsoft headers, but treat them as usual in the user's program. Original Submitter: Melanie Blower (mibintc) Differential Revision: https://reviews.llvm.org/D33782 llvm-svn: 305087 --- clang/lib/Lex/Preprocessor.cpp | 6 +++++- 1 file changed, 5 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 3596337c245..77b46ae5ccc 100644 --- a/clang/lib/Lex/Preprocessor.cpp +++ b/clang/lib/Lex/Preprocessor.cpp @@ -580,7 +580,11 @@ IdentifierInfo *Preprocessor::LookUpIdentifierInfo(Token &Identifier) const { // Update the token info (identifier info and appropriate token kind). Identifier.setIdentifierInfo(II); - Identifier.setKind(II->getTokenID()); + if (getLangOpts().MSVCCompat && II->isCPlusPlusOperatorKeyword() && + getSourceManager().isInSystemHeader(Identifier.getLocation())) + Identifier.setKind(clang::tok::identifier); + else + Identifier.setKind(II->getTokenID()); return II; } -- cgit v1.2.3