summaryrefslogtreecommitdiffstats
path: root/clang/lib/AST/CommentLexer.cpp
diff options
context:
space:
mode:
authorBenjamin Kramer <benny.kra@googlemail.com>2013-12-01 15:09:32 +0000
committerBenjamin Kramer <benny.kra@googlemail.com>2013-12-01 15:09:32 +0000
commit2dece5747a0f7bd711a5d8fa93b613351f7b6e07 (patch)
tree327d6bb547f85217a38a073966d286bb34690baf /clang/lib/AST/CommentLexer.cpp
parent45479dcf49845d2faace66c12921be1412721265 (diff)
downloadbcm5719-llvm-2dece5747a0f7bd711a5d8fa93b613351f7b6e07.tar.gz
bcm5719-llvm-2dece5747a0f7bd711a5d8fa93b613351f7b6e07.zip
CommentLexer: When proceeding with a typo corrected name don't clobber the token.
This would crash if the token is used in another diagnostic. PR18051. llvm-svn: 196048
Diffstat (limited to 'clang/lib/AST/CommentLexer.cpp')
-rw-r--r--clang/lib/AST/CommentLexer.cpp11
1 files changed, 6 insertions, 5 deletions
diff --git a/clang/lib/AST/CommentLexer.cpp b/clang/lib/AST/CommentLexer.cpp
index 475532d9a99..01ed3ce80a6 100644
--- a/clang/lib/AST/CommentLexer.cpp
+++ b/clang/lib/AST/CommentLexer.cpp
@@ -353,16 +353,17 @@ void Lexer::lexCommentText(Token &T) {
const CommandInfo *Info = Traits.getCommandInfoOrNULL(CommandName);
if (!Info) {
- formTokenWithChars(T, TokenPtr, tok::unknown_command);
- T.setUnknownCommandName(CommandName);
if ((Info = Traits.getTypoCorrectCommandInfo(CommandName))) {
StringRef CorrectedName = Info->Name;
- SourceRange CommandRange(T.getLocation().getLocWithOffset(1),
- T.getEndLocation());
- Diag(T.getLocation(), diag::warn_correct_comment_command_name)
+ SourceLocation Loc = getSourceLocation(BufferPtr);
+ SourceRange CommandRange(Loc.getLocWithOffset(1),
+ getSourceLocation(TokenPtr));
+ Diag(Loc, diag::warn_correct_comment_command_name)
<< CommandName << CorrectedName
<< FixItHint::CreateReplacement(CommandRange, CorrectedName);
} else {
+ formTokenWithChars(T, TokenPtr, tok::unknown_command);
+ T.setUnknownCommandName(CommandName);
Diag(T.getLocation(), diag::warn_unknown_comment_command_name);
return;
}
OpenPOWER on IntegriCloud