[Doc parsing] Provide diagnostics for unknown documentation
commands. // rdar://12381408
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@181071 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/AST/CommentLexer.cpp b/lib/AST/CommentLexer.cpp
index 1194520..82efac6 100644
--- a/lib/AST/CommentLexer.cpp
+++ b/lib/AST/CommentLexer.cpp
@@ -1,4 +1,5 @@
#include "clang/AST/CommentLexer.h"
+#include "clang/Lex/LexDiagnostic.h"
#include "clang/AST/CommentCommandTraits.h"
#include "clang/Basic/CharInfo.h"
#include "llvm/ADT/StringExtras.h"
@@ -353,6 +354,8 @@
if (!Info) {
formTokenWithChars(T, TokenPtr, tok::unknown_command);
T.setUnknownCommandName(CommandName);
+ Diag(T.getLocation(),
+ diag::warn_unknown_comment_command_name);
return;
}
if (Info->IsVerbatimBlockCommand) {
@@ -685,10 +688,11 @@
State = LS_Normal;
}
-Lexer::Lexer(llvm::BumpPtrAllocator &Allocator, const CommandTraits &Traits,
+Lexer::Lexer(llvm::BumpPtrAllocator &Allocator, DiagnosticsEngine &Diags,
+ const CommandTraits &Traits,
SourceLocation FileLoc,
const char *BufferStart, const char *BufferEnd):
- Allocator(Allocator), Traits(Traits),
+ Allocator(Allocator), Diags(Diags), Traits(Traits),
BufferStart(BufferStart), BufferEnd(BufferEnd),
FileLoc(FileLoc), BufferPtr(BufferStart),
CommentState(LCS_BeforeComment), State(LS_Normal) {
diff --git a/lib/AST/RawCommentList.cpp b/lib/AST/RawCommentList.cpp
index fb85c14..92b96dc 100644
--- a/lib/AST/RawCommentList.cpp
+++ b/lib/AST/RawCommentList.cpp
@@ -146,7 +146,8 @@
// a separate allocator for all temporary stuff.
llvm::BumpPtrAllocator Allocator;
- comments::Lexer L(Allocator, Context.getCommentCommandTraits(),
+ comments::Lexer L(Allocator, Context.getDiagnostics(),
+ Context.getCommentCommandTraits(),
Range.getBegin(),
RawText.begin(), RawText.end());
comments::BriefParser P(L, Context.getCommentCommandTraits());
@@ -167,7 +168,8 @@
// Make sure that RawText is valid.
getRawText(Context.getSourceManager());
- comments::Lexer L(Context.getAllocator(), Context.getCommentCommandTraits(),
+ comments::Lexer L(Context.getAllocator(), Context.getDiagnostics(),
+ Context.getCommentCommandTraits(),
getSourceRange().getBegin(),
RawText.begin(), RawText.end());
comments::Sema S(Context.getAllocator(), Context.getSourceManager(),