From 0321b8ffd6de8c6fda99cc3daeb08d33fe8ff03e Mon Sep 17 00:00:00 2001 From: Fariborz Jahanian Date: Thu, 9 May 2013 17:18:52 +0000 Subject: [PATCH] [doc parsing]: make single character command impostures warn in pedantic mode. llvm-svn: 181523 --- clang/lib/AST/CommentCommandTraits.cpp | 5 +++++ clang/lib/AST/CommentLexer.cpp | 4 ---- clang/test/Sema/warn-documentation.m | 4 ++++ 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/clang/lib/AST/CommentCommandTraits.cpp b/clang/lib/AST/CommentCommandTraits.cpp index dc4744a53c59..6baf4a9dc6b1 100644 --- a/clang/lib/AST/CommentCommandTraits.cpp +++ b/clang/lib/AST/CommentCommandTraits.cpp @@ -68,6 +68,11 @@ HelperTypoCorrectCommandInfo(SmallVectorImpl &BestCommand, const CommandInfo * CommandTraits::getTypoCorrectCommandInfo(StringRef Typo) const { + // single character command impostures, such as \t or \n must not go + // through the fixit logic. + if (Typo.size() <= 1) + return NULL; + SmallVector BestCommand; int NumOfCommands = sizeof(Commands) / sizeof(CommandInfo); diff --git a/clang/lib/AST/CommentLexer.cpp b/clang/lib/AST/CommentLexer.cpp index c589219f06ff..b195d52e8ef1 100644 --- a/clang/lib/AST/CommentLexer.cpp +++ b/clang/lib/AST/CommentLexer.cpp @@ -355,10 +355,6 @@ 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), diff --git a/clang/test/Sema/warn-documentation.m b/clang/test/Sema/warn-documentation.m index 0737a8dedd03..14e0c347e3f9 100644 --- a/clang/test/Sema/warn-documentation.m +++ b/clang/test/Sema/warn-documentation.m @@ -172,3 +172,7 @@ struct S; @struct S1 THIS IS IT */ @interface S1 @end + +// expected-warning@+1 {{unknown command tag name}} +/// \t bbb IS_DOXYGEN_END +int FooBar();