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

Dmitri Gribenko gribozavr at gmail.com
Thu May 9 10:15:44 PDT 2013


On Thu, May 9, 2013 at 8:03 PM, jahanian <fjahanian at apple.com> wrote:
>
> On May 9, 2013, at 10:01 AM, Dmitri Gribenko <gribozavr at gmail.com> wrote:
>
> 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.
>
>
> Are you sure. I intentionally left it out. It is going to be noisy with
> pedantic.

Pedantic is going to be noisy anyway, because it will warn even if
there is no typo correction available.  Pedantic should be, erm,
pedantic, and warn about everything suspect -- that's the intent.  It
is feasible to be pedantic-clean when starting a new project (like
clang codebase does), but for an existing project it will be noisy,
and that's why it is off by default.

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