summaryrefslogtreecommitdiffstats
path: root/clang/lib/AST/RawCommentList.cpp
diff options
context:
space:
mode:
authorDmitri Gribenko <gribozavr@gmail.com>2012-08-14 17:17:18 +0000
committerDmitri Gribenko <gribozavr@gmail.com>2012-08-14 17:17:18 +0000
commitb261088a618d17ba71d8982093c8767da0e0e67a (patch)
tree1fbcef7d243850b7e9d0851c788e6ceb7b424bce /clang/lib/AST/RawCommentList.cpp
parent378b292aab4c80f2926dd0ed331ba15b8a0875d3 (diff)
downloadbcm5719-llvm-b261088a618d17ba71d8982093c8767da0e0e67a.tar.gz
bcm5719-llvm-b261088a618d17ba71d8982093c8767da0e0e67a.zip
Attaching comments to redeclarations: fix wrong assumptions
The reason for the recent fallout for "attaching comments to any redeclaration" change are two false assumptions: (1) a RawComment is attached to a single decl (not true for 'typedef struct X *Y' where we want the comment to be attached to both X and Y); (2) the whole redeclaration chain has only a single comment (obviously false, the user can put a separate comment for each redeclaration). To fix (1) I revert the part of the recent change where a 'Decl*' member was introduced to RawComment. Now ASTContext has a separate DenseMap for mapping 'Decl*' to 'FullComment*'. To fix (2) I just removed the test with this assumption. We might not parse every comment in redecl chain if we already parsed at least one. llvm-svn: 161878
Diffstat (limited to 'clang/lib/AST/RawCommentList.cpp')
-rw-r--r--clang/lib/AST/RawCommentList.cpp21
1 files changed, 5 insertions, 16 deletions
diff --git a/clang/lib/AST/RawCommentList.cpp b/clang/lib/AST/RawCommentList.cpp
index c704cabe69f..a5a32870577 100644
--- a/clang/lib/AST/RawCommentList.cpp
+++ b/clang/lib/AST/RawCommentList.cpp
@@ -65,7 +65,7 @@ bool mergedCommentIsTrailingComment(StringRef Comment) {
RawComment::RawComment(const SourceManager &SourceMgr, SourceRange SR,
bool Merged) :
Range(SR), RawTextValid(false), BriefTextValid(false),
- IsAlmostTrailingComment(false),
+ IsAttached(false), IsAlmostTrailingComment(false),
BeginLineValid(false), EndLineValid(false) {
// Extract raw comment text, if possible.
if (SR.getBegin() == SR.getEnd() || getRawText(SourceMgr).empty()) {
@@ -87,16 +87,6 @@ RawComment::RawComment(const SourceManager &SourceMgr, SourceRange SR,
}
}
-const Decl *RawComment::getDecl() const {
- if (DeclOrParsedComment.isNull())
- return NULL;
-
- if (const Decl *D = DeclOrParsedComment.dyn_cast<const Decl *>())
- return D;
-
- return DeclOrParsedComment.get<comments::FullComment *>()->getDecl();
-}
-
unsigned RawComment::getBeginLine(const SourceManager &SM) const {
if (BeginLineValid)
return BeginLine;
@@ -169,7 +159,8 @@ const char *RawComment::extractBriefText(const ASTContext &Context) const {
return BriefTextPtr;
}
-comments::FullComment *RawComment::parse(const ASTContext &Context) const {
+comments::FullComment *RawComment::parse(const ASTContext &Context,
+ const Decl *D) const {
// Make sure that RawText is valid.
getRawText(Context.getSourceManager());
@@ -179,13 +170,11 @@ comments::FullComment *RawComment::parse(const ASTContext &Context) const {
RawText.begin(), RawText.end());
comments::Sema S(Context.getAllocator(), Context.getSourceManager(),
Context.getDiagnostics(), Traits);
- S.setDecl(getDecl());
+ S.setDecl(D);
comments::Parser P(L, S, Context.getAllocator(), Context.getSourceManager(),
Context.getDiagnostics(), Traits);
- comments::FullComment *FC = P.parseFullComment();
- DeclOrParsedComment = FC;
- return FC;
+ return P.parseFullComment();
}
namespace {
OpenPOWER on IntegriCloud