[cfe-commits] [PATCH] Introduce diagnostics into comment parsing and semantic analysis
Jordan Rose
jordan_rose at apple.com
Wed Jul 11 09:44:02 PDT 2012
Oops, one more comment.
+ unsigned CorrectedParamIndex = ParamCommandComment::InvalidParamIndex;
+ if (FD->param_size() == 1) {
+ // If function has only one parameter then only that parameter
+ // can be documented.
+ CorrectedParamIndex = 0;
+ } else {
+ // Do typo correction.
+ CorrectedParamIndex = correctTypoInParmVarReference(Arg, FD);
+ }
+ if (CorrectedParamIndex != ParamCommandComment::InvalidParamIndex) {
+ const ParmVarDecl *CorrectedPVD = FD->getParamDecl(CorrectedParamIndex);
+ if (const IdentifierInfo *CorrectedII = CorrectedPVD->getIdentifier())
+ Diag(ArgLocBegin, diag::note_doc_param_name_suggestion)
+ << CorrectedII->getName()
+ << FixItHint::CreateReplacement(ArgRange, CorrectedII->getName());
+ }
The most common mistake I make when writing \param documentation is actually to leave out the name of the parameter, particularly when the function only has one parameter. I can't actually think of a way to catch this easily, but it makes me more wary of the one-parameter correction case. Then again, the fixit's on a note, so I guess it's not too bad.
More information about the cfe-commits
mailing list