aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/Lex/Lexer.cpp
diff options
context:
space:
mode:
authorJordan Rose <jordan_rose@apple.com>2013-01-24 20:50:52 +0000
committerJordan Rose <jordan_rose@apple.com>2013-01-24 20:50:52 +0000
commit62db5066e91e966b4b31fedd2a21fb9ab28118be (patch)
tree1e9fcabda59c48517a55e69325e7d6abf62cee2c /clang/lib/Lex/Lexer.cpp
parent4246ae0089571a1cbf357d7c4570e07c0193733c (diff)
downloadllvm-62db5066e91e966b4b31fedd2a21fb9ab28118be.zip
llvm-62db5066e91e966b4b31fedd2a21fb9ab28118be.tar.gz
llvm-62db5066e91e966b4b31fedd2a21fb9ab28118be.tar.bz2
Add a fixit for \U1234 -> \u1234.
llvm-svn: 173371
Diffstat (limited to 'clang/lib/Lex/Lexer.cpp')
-rw-r--r--clang/lib/Lex/Lexer.cpp10
1 files changed, 9 insertions, 1 deletions
diff --git a/clang/lib/Lex/Lexer.cpp b/clang/lib/Lex/Lexer.cpp
index 2a57e6f..a4d6a2e 100644
--- a/clang/lib/Lex/Lexer.cpp
+++ b/clang/lib/Lex/Lexer.cpp
@@ -2725,8 +2725,16 @@ uint32_t Lexer::tryReadUCN(const char *&StartPtr, const char *SlashLoc,
Diag(BufferPtr, diag::warn_ucn_escape_no_digits)
<< StringRef(KindLoc, 1);
} else {
- // FIXME: if i == 4 and NumHexDigits == 8, suggest a fixit to \u.
Diag(BufferPtr, diag::warn_ucn_escape_incomplete);
+
+ // If the user wrote \U1234, suggest a fixit to \u.
+ if (i == 4 && NumHexDigits == 8) {
+ CharSourceRange URange =
+ CharSourceRange::getCharRange(getSourceLocation(KindLoc),
+ getSourceLocation(KindLoc + 1));
+ Diag(KindLoc, diag::note_ucn_four_not_eight)
+ << FixItHint::CreateReplacement(URange, "u");
+ }
}
}