aboutsummaryrefslogtreecommitdiff
path: root/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
commitb87672b124ab4fbe6f2cabc2ad71655fc71230ea (patch)
treec053e43c9306617ec9babf87f0ef654f656a8ac6 /lib/Lex/Lexer.cpp
parentfc12060ed595fd23d731b8a86adb21ddbb8c7bfb (diff)
Add a fixit for \U1234 -> \u1234.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@173371 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Lex/Lexer.cpp')
-rw-r--r--lib/Lex/Lexer.cpp10
1 files changed, 9 insertions, 1 deletions
diff --git a/lib/Lex/Lexer.cpp b/lib/Lex/Lexer.cpp
index 2a57e6fced..a4d6a2e8f7 100644
--- a/lib/Lex/Lexer.cpp
+++ b/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");
+ }
}
}