aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDmitri Gribenko <gribozavr@gmail.com>2012-10-19 16:51:38 +0000
committerDmitri Gribenko <gribozavr@gmail.com>2012-10-19 16:51:38 +0000
commit8cfabf2cb278efc1f694f1d9aab76888a60ee3ac (patch)
tree9f08e5687c50325e270404f309616dc1459273a0
parent535a5d001b2035a7aa68ee368fbe44ec90e33740 (diff)
Remove const_casts by propagating constness down to called functions.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@166287 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--include/clang/AST/Comment.h8
-rw-r--r--lib/AST/Comment.cpp6
-rw-r--r--lib/AST/CommentDumper.cpp4
-rw-r--r--tools/libclang/CXComment.cpp16
4 files changed, 16 insertions, 18 deletions
diff --git a/include/clang/AST/Comment.h b/include/clang/AST/Comment.h
index 33a24df43d..316a1801bd 100644
--- a/include/clang/AST/Comment.h
+++ b/include/clang/AST/Comment.h
@@ -706,8 +706,8 @@ public:
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 @@ public:
return getNumArgs() > 0;
}
- StringRef getParamName(comments::FullComment *FC) const;
-
+ StringRef getParamName(const FullComment *FC) const;
+
StringRef getParamNameAsWritten() const {
return Args[0].Text;
}
diff --git a/lib/AST/Comment.cpp b/lib/AST/Comment.cpp
index edb0f60fdf..361f8ac61c 100644
--- a/lib/AST/Comment.cpp
+++ b/lib/AST/Comment.cpp
@@ -305,12 +305,12 @@ void DeclInfo::fill() {
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 @@ StringRef TParamCommandComment::getParamName(comments::FullComment *FC) const {
}
return "";
}
-
+
} // end namespace comments
} // end namespace clang
diff --git a/lib/AST/CommentDumper.cpp b/lib/AST/CommentDumper.cpp
index 18ba47ff6c..18d3406217 100644
--- a/lib/AST/CommentDumper.cpp
+++ b/lib/AST/CommentDumper.cpp
@@ -188,7 +188,7 @@ void CommentDumper::visitParamCommandComment(const ParamCommandComment *C) {
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 @@ void CommentDumper::visitTParamCommandComment(const TParamCommandComment *C) {
if (C->hasParamName()) {
if (C->isPositionValid())
- OS << " Param=\"" << C->getParamName(const_cast<FullComment*>(FC)) << "\"";
+ OS << " Param=\"" << C->getParamName(FC) << "\"";
else
OS << " Param=\"" << C->getParamNameAsWritten() << "\"";
}
diff --git a/tools/libclang/CXComment.cpp b/tools/libclang/CXComment.cpp
index 6f3f382444..0c3b8c7388 100644
--- a/tools/libclang/CXComment.cpp
+++ b/tools/libclang/CXComment.cpp
@@ -536,7 +536,7 @@ class CommentASTToHTMLConverter :
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 @@ public:
void appendToResultWithHTMLEscaping(StringRef S);
private:
- FullComment *FC;
+ const FullComment *FC;
/// Output stream for HTML.
llvm::raw_svector_ostream Result;
@@ -844,8 +844,7 @@ CXString clang_FullComment_getAsHTML(CXComment CXC) {
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 @@ class CommentASTToXMLConverter :
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 @@ public:
void appendToResultWithXMLEscaping(StringRef S);
private:
- FullComment *FC;
-
+ const FullComment *FC;
+
/// Output stream for XML.
llvm::raw_svector_ostream Result;
@@ -1325,8 +1324,7 @@ CXString clang_FullComment_getAsXML(CXComment CXC) {
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);
}