From 5cd4c41422b8d65a08e0ec007743d7a0ae72ec27 Mon Sep 17 00:00:00 2001 From: Fariborz Jahanian Date: Thu, 9 May 2013 16:44:02 +0000 Subject: [PATCH] [doc parsing]: So, in this patch, single character 'commands' will not go through typo fixit logic, preserving the old behavior (no typo, no diagnostics). // rdar://12381408 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@181521 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/AST/CommentCommandTraits.cpp | 4 ---- lib/AST/CommentLexer.cpp | 4 ++++ 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/AST/CommentCommandTraits.cpp b/lib/AST/CommentCommandTraits.cpp index 2b5e624fb7..dc4744a53c 100644 --- a/lib/AST/CommentCommandTraits.cpp +++ b/lib/AST/CommentCommandTraits.cpp @@ -49,10 +49,6 @@ HelperTypoCorrectCommandInfo(SmallVectorImpl &BestCommand, const unsigned MaxEditDistance = 1; unsigned BestEditDistance = MaxEditDistance + 1; StringRef Name = Command->Name; - // Don't attempt trying to typo fix single character commands. - // \t and \n are very common - if (Name.size() <= 1) - return; unsigned MinPossibleEditDistance = abs((int)Name.size() - (int)Typo.size()); if (MinPossibleEditDistance > 0 && diff --git a/lib/AST/CommentLexer.cpp b/lib/AST/CommentLexer.cpp index b195d52e8e..c589219f06 100644 --- a/lib/AST/CommentLexer.cpp +++ b/lib/AST/CommentLexer.cpp @@ -355,6 +355,10 @@ void Lexer::lexCommentText(Token &T) { if (!Info) { formTokenWithChars(T, TokenPtr, tok::unknown_command); T.setUnknownCommandName(CommandName); + // single character command impostures, such as \t or \n must not go + // through the fixit logic. + if (CommandName.size() <= 1) + return; if ((Info = Traits.getTypoCorrectCommandInfo(CommandName))) { StringRef CorrectedName = Info->Name; SourceRange CommandRange(T.getLocation().getLocWithOffset(1), -- 2.40.0