[cfe-commits] r166287 - in /cfe/trunk: include/clang/AST/Comment.h lib/AST/Comment.cpp lib/AST/CommentDumper.cpp tools/libclang/CXComment.cpp
Dmitri Gribenko
gribozavr at gmail.com
Fri Oct 19 09:51:38 PDT 2012
Author: gribozavr
Date: Fri Oct 19 11:51:38 2012
New Revision: 166287
URL: http://llvm.org/viewvc/llvm-project?rev=166287&view=rev
Log:
Remove const_casts by propagating constness down to called functions.
Modified:
cfe/trunk/include/clang/AST/Comment.h
cfe/trunk/lib/AST/Comment.cpp
cfe/trunk/lib/AST/CommentDumper.cpp
cfe/trunk/tools/libclang/CXComment.cpp
Modified: cfe/trunk/include/clang/AST/Comment.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Comment.h?rev=166287&r1=166286&r2=166287&view=diff
==============================================================================
--- cfe/trunk/include/clang/AST/Comment.h (original)
+++ cfe/trunk/include/clang/AST/Comment.h Fri Oct 19 11:51:38 2012
@@ -706,8 +706,8 @@
return getNumArgs() > 0;
}
- StringRef getParamName(comments::FullComment *FC) const;
-
+ StringRef getParamName(const FullComment *FC) const;
+
StringRef getParamNameAsWritten() const {
return Args[0].Text;
}
@@ -763,8 +763,8 @@
return getNumArgs() > 0;
}
- StringRef getParamName(comments::FullComment *FC) const;
-
+ StringRef getParamName(const FullComment *FC) const;
+
StringRef getParamNameAsWritten() const {
return Args[0].Text;
}
Modified: cfe/trunk/lib/AST/Comment.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/Comment.cpp?rev=166287&r1=166286&r2=166287&view=diff
==============================================================================
--- cfe/trunk/lib/AST/Comment.cpp (original)
+++ cfe/trunk/lib/AST/Comment.cpp Fri Oct 19 11:51:38 2012
@@ -305,12 +305,12 @@
IsFilled = true;
}
-StringRef ParamCommandComment::getParamName(comments::FullComment *FC) const {
+StringRef ParamCommandComment::getParamName(const FullComment *FC) const {
assert(isParamIndexValid());
return FC->getThisDeclInfo()->ParamVars[getParamIndex()]->getName();
}
-StringRef TParamCommandComment::getParamName(comments::FullComment *FC) const {
+StringRef TParamCommandComment::getParamName(const FullComment *FC) const {
assert(isPositionValid());
const TemplateParameterList *TPL = FC->getThisDeclInfo()->TemplateParameters;
for (unsigned i = 0, e = getDepth(); i != e; ++i) {
@@ -323,7 +323,7 @@
}
return "";
}
-
+
} // end namespace comments
} // end namespace clang
Modified: cfe/trunk/lib/AST/CommentDumper.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/CommentDumper.cpp?rev=166287&r1=166286&r2=166287&view=diff
==============================================================================
--- cfe/trunk/lib/AST/CommentDumper.cpp (original)
+++ cfe/trunk/lib/AST/CommentDumper.cpp Fri Oct 19 11:51:38 2012
@@ -188,7 +188,7 @@
if (C->hasParamName()) {
if (C->isParamIndexValid())
- OS << " Param=\"" << C->getParamName(const_cast<FullComment*>(FC)) << "\"";
+ OS << " Param=\"" << C->getParamName(FC) << "\"";
else
OS << " Param=\"" << C->getParamNameAsWritten() << "\"";
}
@@ -202,7 +202,7 @@
if (C->hasParamName()) {
if (C->isPositionValid())
- OS << " Param=\"" << C->getParamName(const_cast<FullComment*>(FC)) << "\"";
+ OS << " Param=\"" << C->getParamName(FC) << "\"";
else
OS << " Param=\"" << C->getParamNameAsWritten() << "\"";
}
Modified: cfe/trunk/tools/libclang/CXComment.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/libclang/CXComment.cpp?rev=166287&r1=166286&r2=166287&view=diff
==============================================================================
--- cfe/trunk/tools/libclang/CXComment.cpp (original)
+++ cfe/trunk/tools/libclang/CXComment.cpp Fri Oct 19 11:51:38 2012
@@ -536,7 +536,7 @@
public ConstCommentVisitor<CommentASTToHTMLConverter> {
public:
/// \param Str accumulator for HTML.
- CommentASTToHTMLConverter(FullComment *FC,
+ CommentASTToHTMLConverter(const FullComment *FC,
SmallVectorImpl<char> &Str,
const CommandTraits &Traits) :
FC(FC), Result(Str), Traits(Traits)
@@ -568,7 +568,7 @@
void appendToResultWithHTMLEscaping(StringRef S);
private:
- FullComment *FC;
+ const FullComment *FC;
/// Output stream for HTML.
llvm::raw_svector_ostream Result;
@@ -844,8 +844,7 @@
return createCXString((const char *) 0);
SmallString<1024> HTML;
- CommentASTToHTMLConverter Converter(const_cast<FullComment *>(FC),
- HTML, getCommandTraits(CXC));
+ CommentASTToHTMLConverter Converter(FC, HTML, getCommandTraits(CXC));
Converter.visit(FC);
return createCXString(HTML.str(), /* DupString = */ true);
}
@@ -857,7 +856,7 @@
public ConstCommentVisitor<CommentASTToXMLConverter> {
public:
/// \param Str accumulator for XML.
- CommentASTToXMLConverter(FullComment *FC,
+ CommentASTToXMLConverter(const FullComment *FC,
SmallVectorImpl<char> &Str,
const CommandTraits &Traits,
const SourceManager &SM) :
@@ -884,8 +883,8 @@
void appendToResultWithXMLEscaping(StringRef S);
private:
- FullComment *FC;
-
+ const FullComment *FC;
+
/// Output stream for XML.
llvm::raw_svector_ostream Result;
@@ -1325,8 +1324,7 @@
SourceManager &SM = static_cast<ASTUnit *>(TU->TUData)->getSourceManager();
SmallString<1024> XML;
- CommentASTToXMLConverter Converter(const_cast<FullComment *>(FC), XML,
- getCommandTraits(CXC), SM);
+ CommentASTToXMLConverter Converter(FC, XML, getCommandTraits(CXC), SM);
Converter.visit(FC);
return createCXString(XML.str(), /* DupString = */ true);
}
More information about the cfe-commits
mailing list