Comment diagnostics: add warning for multiple \param commands with duplicate
parameter names.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@160696 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/AST/CommentSema.cpp b/lib/AST/CommentSema.cpp
index 8fa8ab7..5301bfe 100644
--- a/lib/AST/CommentSema.cpp
+++ b/lib/AST/CommentSema.cpp
@@ -153,6 +153,15 @@
const unsigned ResolvedParamIndex = resolveParmVarReference(Arg, ParamVars);
if (ResolvedParamIndex != ParamCommandComment::InvalidParamIndex) {
Command->setParamIndex(ResolvedParamIndex);
+ if (ParamVarDocs[ResolvedParamIndex]) {
+ SourceRange ArgRange(ArgLocBegin, ArgLocEnd);
+ Diag(ArgLocBegin, diag::warn_doc_param_duplicate)
+ << Arg << ArgRange;
+ ParamCommandComment *PrevCommand = ParamVarDocs[ResolvedParamIndex];
+ Diag(PrevCommand->getLocation(), diag::note_doc_param_previous)
+ << PrevCommand->getParamNameRange();
+ }
+ ParamVarDocs[ResolvedParamIndex] = Command;
return Command;
}
@@ -351,7 +360,6 @@
FullComment *Sema::actOnFullComment(
ArrayRef<BlockContentComment *> Blocks) {
- SmallVector<ParamCommandComment *, 8> Params;
return new (Allocator) FullComment(Blocks);
}
@@ -382,6 +390,7 @@
}
void Sema::inspectThisDecl() {
+ assert(!IsThisDeclInspected);
if (!ThisDecl) {
IsFunctionDecl = false;
ParamVars = ArrayRef<const ParmVarDecl *>();
@@ -397,6 +406,7 @@
IsFunctionDecl = false;
ParamVars = ArrayRef<const ParmVarDecl *>();
}
+ ParamVarDocs.resize(ParamVars.size(), NULL);
IsThisDeclInspected = true;
}