[cfe-commits] r166231 - in /cfe/trunk: include/clang/AST/Comment.h lib/AST/Comment.cpp lib/AST/CommentDumper.cpp lib/AST/CommentSema.cpp tools/libclang/CXComment.cpp unittests/AST/CommentParser.cpp
Fariborz Jahanian
fjahanian at apple.com
Thu Oct 18 14:42:42 PDT 2012
Author: fjahanian
Date: Thu Oct 18 16:42:42 2012
New Revision: 166231
URL: http://llvm.org/viewvc/llvm-project?rev=166231&view=rev
Log:
[doc parsing] use getParamName to access parameter
for current(rewritten) comment and getParamNameAsWritten
to access param name coming with \param marker.
Modified:
cfe/trunk/include/clang/AST/Comment.h
cfe/trunk/lib/AST/Comment.cpp
cfe/trunk/lib/AST/CommentDumper.cpp
cfe/trunk/lib/AST/CommentSema.cpp
cfe/trunk/tools/libclang/CXComment.cpp
cfe/trunk/unittests/AST/CommentParser.cpp
Modified: cfe/trunk/include/clang/AST/Comment.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Comment.h?rev=166231&r1=166230&r2=166231&view=diff
==============================================================================
--- cfe/trunk/include/clang/AST/Comment.h (original)
+++ cfe/trunk/include/clang/AST/Comment.h Thu Oct 18 16:42:42 2012
@@ -707,6 +707,10 @@
}
StringRef getParamName(comments::FullComment *FC) const;
+
+ StringRef getParamNameAsWritten() const {
+ return Args[0].Text;
+ }
SourceRange getParamNameRange() const {
return Args[0].Range;
@@ -760,6 +764,10 @@
}
StringRef getParamName(comments::FullComment *FC) const;
+
+ StringRef getParamNameAsWritten() const {
+ return Args[0].Text;
+ }
SourceRange getParamNameRange() const {
return Args[0].Range;
Modified: cfe/trunk/lib/AST/Comment.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/Comment.cpp?rev=166231&r1=166230&r2=166231&view=diff
==============================================================================
--- cfe/trunk/lib/AST/Comment.cpp (original)
+++ cfe/trunk/lib/AST/Comment.cpp Thu Oct 18 16:42:42 2012
@@ -306,24 +306,22 @@
}
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
Modified: cfe/trunk/lib/AST/CommentDumper.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/CommentDumper.cpp?rev=166231&r1=166230&r2=166231&view=diff
==============================================================================
--- cfe/trunk/lib/AST/CommentDumper.cpp (original)
+++ cfe/trunk/lib/AST/CommentDumper.cpp Thu Oct 18 16:42:42 2012
@@ -186,8 +186,12 @@
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 @@
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()) {
Modified: cfe/trunk/lib/AST/CommentSema.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/CommentSema.cpp?rev=166231&r1=166230&r2=166231&view=diff
==============================================================================
--- cfe/trunk/lib/AST/CommentSema.cpp (original)
+++ cfe/trunk/lib/AST/CommentSema.cpp Thu Oct 18 16:42:42 2012
@@ -574,7 +574,7 @@
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 @@
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;
Modified: cfe/trunk/tools/libclang/CXComment.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/libclang/CXComment.cpp?rev=166231&r1=166230&r2=166231&view=diff
==============================================================================
--- cfe/trunk/tools/libclang/CXComment.cpp (original)
+++ cfe/trunk/tools/libclang/CXComment.cpp Thu Oct 18 16:42:42 2012
@@ -255,7 +255,7 @@
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 @@
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 @@
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 @@
<< "\">";
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::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::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) {
Modified: cfe/trunk/unittests/AST/CommentParser.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/AST/CommentParser.cpp?rev=166231&r1=166230&r2=166231&view=diff
==============================================================================
--- cfe/trunk/unittests/AST/CommentParser.cpp (original)
+++ cfe/trunk/unittests/AST/CommentParser.cpp Thu Oct 18 16:42:42 2012
@@ -213,7 +213,7 @@
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 @@
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()
More information about the cfe-commits
mailing list