r181521 - [doc parsing]: So, in this patch, single character

Fariborz Jahanian fjahanian at apple.com
Thu May 9 09:44:02 PDT 2013


Author: fjahanian
Date: Thu May  9 11:44:02 2013
New Revision: 181521

URL: http://llvm.org/viewvc/llvm-project?rev=181521&view=rev
Log:
[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

Modified:
    cfe/trunk/lib/AST/CommentCommandTraits.cpp
    cfe/trunk/lib/AST/CommentLexer.cpp

Modified: cfe/trunk/lib/AST/CommentCommandTraits.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/CommentCommandTraits.cpp?rev=181521&r1=181520&r2=181521&view=diff
==============================================================================
--- cfe/trunk/lib/AST/CommentCommandTraits.cpp (original)
+++ cfe/trunk/lib/AST/CommentCommandTraits.cpp Thu May  9 11:44:02 2013
@@ -49,10 +49,6 @@ HelperTypoCorrectCommandInfo(SmallVector
   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 &&

Modified: cfe/trunk/lib/AST/CommentLexer.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/CommentLexer.cpp?rev=181521&r1=181520&r2=181521&view=diff
==============================================================================
--- cfe/trunk/lib/AST/CommentLexer.cpp (original)
+++ cfe/trunk/lib/AST/CommentLexer.cpp Thu May  9 11:44:02 2013
@@ -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),





More information about the cfe-commits mailing list