[doc parsing] use getParamName to access parameter
for current(rewritten) comment and getParamNameAsWritten to access param name coming with \param marker. llvm-svn: 166231
This commit is contained in:
parent
43897975cc
commit
9d2f1e753b
|
@ -707,6 +707,10 @@ public:
|
|||
}
|
||||
|
||||
StringRef getParamName(comments::FullComment *FC) const;
|
||||
|
||||
StringRef getParamNameAsWritten() const {
|
||||
return Args[0].Text;
|
||||
}
|
||||
|
||||
SourceRange getParamNameRange() const {
|
||||
return Args[0].Range;
|
||||
|
@ -760,6 +764,10 @@ public:
|
|||
}
|
||||
|
||||
StringRef getParamName(comments::FullComment *FC) const;
|
||||
|
||||
StringRef getParamNameAsWritten() const {
|
||||
return Args[0].Text;
|
||||
}
|
||||
|
||||
SourceRange getParamNameRange() const {
|
||||
return Args[0].Range;
|
||||
|
|
|
@ -306,24 +306,22 @@ void DeclInfo::fill() {
|
|||
}
|
||||
|
||||
StringRef ParamCommandComment::getParamName(comments::FullComment *FC) const {
|
||||
if (FC && isParamIndexValid())
|
||||
return FC->getThisDeclInfo()->ParamVars[getParamIndex()]->getName();
|
||||
return Args[0].Text;
|
||||
assert(isParamIndexValid());
|
||||
return FC->getThisDeclInfo()->ParamVars[getParamIndex()]->getName();
|
||||
}
|
||||
|
||||
StringRef TParamCommandComment::getParamName(comments::FullComment *FC) const {
|
||||
if (FC && isPositionValid()) {
|
||||
const TemplateParameterList *TPL = FC->getThisDeclInfo()->TemplateParameters;
|
||||
for (unsigned i = 0, e = getDepth(); i != e; ++i) {
|
||||
if (i == e-1)
|
||||
return TPL->getParam(getIndex(i))->getName();
|
||||
const NamedDecl *Param = TPL->getParam(getIndex(i));
|
||||
if (const TemplateTemplateParmDecl *TTP =
|
||||
assert(isPositionValid());
|
||||
const TemplateParameterList *TPL = FC->getThisDeclInfo()->TemplateParameters;
|
||||
for (unsigned i = 0, e = getDepth(); i != e; ++i) {
|
||||
if (i == e-1)
|
||||
return TPL->getParam(getIndex(i))->getName();
|
||||
const NamedDecl *Param = TPL->getParam(getIndex(i));
|
||||
if (const TemplateTemplateParmDecl *TTP =
|
||||
dyn_cast<TemplateTemplateParmDecl>(Param))
|
||||
TPL = TTP->getTemplateParameters();
|
||||
}
|
||||
TPL = TTP->getTemplateParameters();
|
||||
}
|
||||
return Args[0].Text;
|
||||
return "";
|
||||
}
|
||||
|
||||
} // end namespace comments
|
||||
|
|
|
@ -186,8 +186,12 @@ void CommentDumper::visitParamCommandComment(const ParamCommandComment *C) {
|
|||
else
|
||||
OS << " implicitly";
|
||||
|
||||
if (C->hasParamName())
|
||||
OS << " Param=\"" << C->getParamName(const_cast<FullComment*>(FC)) << "\"";
|
||||
if (C->hasParamName()) {
|
||||
if (C->isParamIndexValid())
|
||||
OS << " Param=\"" << C->getParamName(const_cast<FullComment*>(FC)) << "\"";
|
||||
else
|
||||
OS << " Param=\"" << C->getParamNameAsWritten() << "\"";
|
||||
}
|
||||
|
||||
if (C->isParamIndexValid())
|
||||
OS << " ParamIndex=" << C->getParamIndex();
|
||||
|
@ -197,7 +201,10 @@ void CommentDumper::visitTParamCommandComment(const TParamCommandComment *C) {
|
|||
dumpComment(C);
|
||||
|
||||
if (C->hasParamName()) {
|
||||
OS << " Param=\"" << C->getParamName(const_cast<FullComment*>(FC)) << "\"";
|
||||
if (C->isPositionValid())
|
||||
OS << " Param=\"" << C->getParamName(const_cast<FullComment*>(FC)) << "\"";
|
||||
else
|
||||
OS << " Param=\"" << C->getParamNameAsWritten() << "\"";
|
||||
}
|
||||
|
||||
if (C->isPositionValid()) {
|
||||
|
|
|
@ -574,7 +574,7 @@ void Sema::resolveParamCommandIndexes(const FullComment *FC) {
|
|||
ParamCommandComment *PCC = dyn_cast<ParamCommandComment>(*I);
|
||||
if (!PCC || !PCC->hasParamName())
|
||||
continue;
|
||||
StringRef ParamName = PCC->getParamName(0);
|
||||
StringRef ParamName = PCC->getParamNameAsWritten();
|
||||
|
||||
// Check that referenced parameter name is in the function decl.
|
||||
const unsigned ResolvedParamIndex = resolveParmVarReference(ParamName,
|
||||
|
@ -609,7 +609,7 @@ void Sema::resolveParamCommandIndexes(const FullComment *FC) {
|
|||
const ParamCommandComment *PCC = UnresolvedParamCommands[i];
|
||||
|
||||
SourceRange ArgRange = PCC->getParamNameRange();
|
||||
StringRef ParamName = PCC->getParamName(0);
|
||||
StringRef ParamName = PCC->getParamNameAsWritten();
|
||||
Diag(ArgRange.getBegin(), diag::warn_doc_param_not_found)
|
||||
<< ParamName << ArgRange;
|
||||
|
||||
|
|
|
@ -255,7 +255,7 @@ CXString clang_ParamCommandComment_getParamName(CXComment CXC) {
|
|||
if (!PCC || !PCC->hasParamName())
|
||||
return createCXString((const char *) 0);
|
||||
|
||||
return createCXString(PCC->getParamName(0), /*DupString=*/ false);
|
||||
return createCXString(PCC->getParamNameAsWritten(), /*DupString=*/ false);
|
||||
}
|
||||
|
||||
unsigned clang_ParamCommandComment_isParamIndexValid(CXComment CXC) {
|
||||
|
@ -306,7 +306,7 @@ CXString clang_TParamCommandComment_getParamName(CXComment CXC) {
|
|||
if (!TPCC || !TPCC->hasParamName())
|
||||
return createCXString((const char *) 0);
|
||||
|
||||
return createCXString(TPCC->getParamName(0), /*DupString=*/ false);
|
||||
return createCXString(TPCC->getParamNameAsWritten(), /*DupString=*/ false);
|
||||
}
|
||||
|
||||
unsigned clang_TParamCommandComment_isParamPositionValid(CXComment CXC) {
|
||||
|
@ -669,10 +669,11 @@ void CommentASTToHTMLConverter::visitParamCommandComment(
|
|||
Result << "<dt class=\"param-name-index-"
|
||||
<< C->getParamIndex()
|
||||
<< "\">";
|
||||
} else
|
||||
appendToResultWithHTMLEscaping(C->getParamName(FC));
|
||||
} else {
|
||||
Result << "<dt class=\"param-name-index-invalid\">";
|
||||
|
||||
appendToResultWithHTMLEscaping(C->getParamName(FC));
|
||||
appendToResultWithHTMLEscaping(C->getParamNameAsWritten());
|
||||
}
|
||||
Result << "</dt>";
|
||||
|
||||
if (C->isParamIndexValid()) {
|
||||
|
@ -695,10 +696,12 @@ void CommentASTToHTMLConverter::visitTParamCommandComment(
|
|||
<< "\">";
|
||||
else
|
||||
Result << "<dt class=\"tparam-name-index-other\">";
|
||||
} else
|
||||
appendToResultWithHTMLEscaping(C->getParamName(FC));
|
||||
} else {
|
||||
Result << "<dt class=\"tparam-name-index-invalid\">";
|
||||
|
||||
appendToResultWithHTMLEscaping(C->getParamName(FC));
|
||||
appendToResultWithHTMLEscaping(C->getParamNameAsWritten());
|
||||
}
|
||||
|
||||
Result << "</dt>";
|
||||
|
||||
if (C->isPositionValid()) {
|
||||
|
@ -961,7 +964,8 @@ void CommentASTToXMLConverter::visitBlockCommandComment(const BlockCommandCommen
|
|||
|
||||
void CommentASTToXMLConverter::visitParamCommandComment(const ParamCommandComment *C) {
|
||||
Result << "<Parameter><Name>";
|
||||
appendToResultWithXMLEscaping(C->getParamName(FC));
|
||||
appendToResultWithXMLEscaping(C->isParamIndexValid() ? C->getParamName(FC)
|
||||
: C->getParamNameAsWritten());
|
||||
Result << "</Name>";
|
||||
|
||||
if (C->isParamIndexValid())
|
||||
|
@ -987,7 +991,8 @@ void CommentASTToXMLConverter::visitParamCommandComment(const ParamCommandCommen
|
|||
void CommentASTToXMLConverter::visitTParamCommandComment(
|
||||
const TParamCommandComment *C) {
|
||||
Result << "<Parameter><Name>";
|
||||
appendToResultWithXMLEscaping(C->getParamName(FC));
|
||||
appendToResultWithXMLEscaping(C->isPositionValid() ? C->getParamName(FC)
|
||||
: C->getParamNameAsWritten());
|
||||
Result << "</Name>";
|
||||
|
||||
if (C->isPositionValid() && C->getDepth() == 1) {
|
||||
|
|
|
@ -213,7 +213,7 @@ template <typename T>
|
|||
return ::testing::AssertionFailure()
|
||||
<< "ParamCommandComment has no parameter name";
|
||||
|
||||
StringRef ActualParamName = PCC->hasParamName() ? PCC->getParamName(0) : "";
|
||||
StringRef ActualParamName = PCC->hasParamName() ? PCC->getParamNameAsWritten() : "";
|
||||
if (ActualParamName != ParamName)
|
||||
return ::testing::AssertionFailure()
|
||||
<< "ParamCommandComment has parameter name \"" << ActualParamName.str()
|
||||
|
@ -247,7 +247,7 @@ template <typename T>
|
|||
return ::testing::AssertionFailure()
|
||||
<< "TParamCommandComment has no parameter name";
|
||||
|
||||
StringRef ActualParamName = TPCC->hasParamName() ? TPCC->getParamName(0) : "";
|
||||
StringRef ActualParamName = TPCC->hasParamName() ? TPCC->getParamNameAsWritten() : "";
|
||||
if (ActualParamName != ParamName)
|
||||
return ::testing::AssertionFailure()
|
||||
<< "TParamCommandComment has parameter name \"" << ActualParamName.str()
|
||||
|
|
Loading…
Reference in New Issue