PR37189 Fix incorrect end source location and spelling for a split '>>' token.
authorRichard Smith <richard-llvm@metafoo.co.uk>
Mon, 30 Apr 2018 05:25:48 +0000 (05:25 +0000)
committerRichard Smith <richard-llvm@metafoo.co.uk>
Mon, 30 Apr 2018 05:25:48 +0000 (05:25 +0000)
commitb5f8171a1b955e07c13226d353f4ca53f75a0e8a
treeee5ec5faca7f0d2d43d989d9134938fb80037073
parent64e7a16fe4e8e16792aae1469f298ab658a13454
PR37189 Fix incorrect end source location and spelling for a split '>>' token.

When a '>>' token is split into two '>' tokens (in C++11 onwards), or (as an
extension) when we do the same for other tokens starting with a '>', we can't
just use a location pointing to the first '>' as the location of the split
token, because that would result in our miscomputing the length and spelling
for the token. As a consequence, for example, a refactoring replacing 'A<X>'
with something else would sometimes replace one character too many, and
similarly diagnostics highlighting a template-id source range would highlight
one character too many.

Fix this by creating an expansion range covering the first character of the
'>>' token, whose spelling is '>'. For this to work, we generalize the
expansion range of a macro FileID to be either a token range (the common case)
or a character range (used in this new case).

llvm-svn: 331155
35 files changed:
clang/include/clang/Basic/SourceLocation.h
clang/include/clang/Basic/SourceManager.h
clang/include/clang/Lex/Lexer.h
clang/include/clang/Lex/Preprocessor.h
clang/include/clang/Rewrite/Core/HTMLRewrite.h
clang/lib/ARCMigrate/PlistReporter.cpp
clang/lib/ARCMigrate/TransGCAttrs.cpp
clang/lib/ARCMigrate/TransUnbridgedCasts.cpp
clang/lib/ARCMigrate/TransformActions.cpp
clang/lib/Basic/SourceLocation.cpp
clang/lib/Basic/SourceManager.cpp
clang/lib/CodeGen/CoverageMappingGen.cpp
clang/lib/Edit/EditedSource.cpp
clang/lib/Frontend/DiagnosticRenderer.cpp
clang/lib/Frontend/TextDiagnostic.cpp
clang/lib/Lex/Lexer.cpp
clang/lib/Lex/PPDirectives.cpp
clang/lib/Lex/PPMacroExpansion.cpp
clang/lib/Lex/Preprocessor.cpp
clang/lib/Lex/TokenLexer.cpp
clang/lib/Parse/ParseTemplate.cpp
clang/lib/Rewrite/HTMLRewrite.cpp
clang/lib/Sema/SemaChecking.cpp
clang/lib/Sema/SemaDeclAttr.cpp
clang/lib/Sema/SemaDeclCXX.cpp
clang/lib/Sema/SemaInit.cpp
clang/lib/Sema/SemaType.cpp
clang/lib/Serialization/ASTReader.cpp
clang/lib/Serialization/ASTWriter.cpp
clang/lib/StaticAnalyzer/Core/BugReporter.cpp
clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
clang/test/Misc/diag-greatergreater.cpp [new file with mode: 0644]
clang/test/Parser/cxx0x-decl.cpp
clang/tools/libclang/CIndex.cpp
clang/unittests/Lex/LexerTest.cpp