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

Dmitri Gribenko gribozavr at gmail.com
Thu May 9 10:01:48 PDT 2013


On Thu, May 9, 2013 at 7:44 PM, Fariborz Jahanian <fjahanian at apple.com> wrote:
> 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;

But it should still get a pedantic
diag::warn_unknown_comment_command_name diagnostic.

Dmitri

--
main(i,j){for(i=2;;i++){for(j=2;j<i;j++){if(!(i%j)){j=0;break;}}if
(j){printf("%d\n",i);}}} /*Dmitri Gribenko <gribozavr at gmail.com>*/



More information about the cfe-commits mailing list