]> granicus.if.org Git - clang/commit
Keep the IdentifierInfo in the Token for alternative operator keyword
authorOlivier Goffart <ogoffart@woboq.com>
Fri, 14 Jul 2017 09:23:40 +0000 (09:23 +0000)
committerOlivier Goffart <ogoffart@woboq.com>
Fri, 14 Jul 2017 09:23:40 +0000 (09:23 +0000)
commitbaa150782312a70256b17d5383d7a5cd6c8dec32
tree9075324d5beb893ad0816646da05ee336cae9192
parent655f74219d46484a8df5be7b18a05dab8a8a4275
Keep the IdentifierInfo in the Token for alternative operator keyword

The goal of this commit is to fix clang-format so it does not merge tokens when
using the alternative spelling keywords. (eg: "not foo" should not become "notfoo")

The problem is that Preprocessor::HandleIdentifier used to drop the identifier info
from the token for these keyword. This means the first condition of
TokenAnnotator::spaceRequiredBefore is not met. We could add explicit check for
the spelling in that condition, but I think it is better to keep the IdentifierInfo
and handle the operator keyword explicitly when needed. That actually leads to simpler
code, and probably slightly more efficient as well.

Another side effect of this change is that __identifier(and) will now work as
one would expect, removing a FIXME from the MicrosoftExtensions.cpp test

Differential Revision: https://reviews.llvm.org/D35172

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@308008 91177308-0d34-0410-b5e6-96231b3b80d8
include/clang/Basic/IdentifierTable.h
lib/Lex/PPDirectives.cpp
lib/Lex/PPExpressions.cpp
lib/Lex/Preprocessor.cpp
test/Parser/MicrosoftExtensions.cpp
test/Preprocessor/cxx_oper_keyword.cpp
unittests/Format/FormatTest.cpp