aboutsummaryrefslogtreecommitdiffstats
path: root/include/clang/AST/RawCommentList.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/clang/AST/RawCommentList.h')
-rw-r--r--include/clang/AST/RawCommentList.h23
1 files changed, 17 insertions, 6 deletions
diff --git a/include/clang/AST/RawCommentList.h b/include/clang/AST/RawCommentList.h
index 5dc8694e77e9..1eea56dee622 100644
--- a/include/clang/AST/RawCommentList.h
+++ b/include/clang/AST/RawCommentList.h
@@ -10,8 +10,11 @@
#define LLVM_CLANG_AST_RAWCOMMENTLIST_H
#include "clang/Basic/CommentOptions.h"
+#include "clang/Basic/SourceLocation.h"
#include "clang/Basic/SourceManager.h"
#include "llvm/ADT/ArrayRef.h"
+#include "llvm/ADT/DenseMap.h"
+#include <map>
namespace clang {
@@ -196,17 +199,25 @@ public:
void addComment(const RawComment &RC, const CommentOptions &CommentOpts,
llvm::BumpPtrAllocator &Allocator);
- ArrayRef<RawComment *> getComments() const {
- return Comments;
- }
+ /// \returns A mapping from an offset of the start of the comment to the
+ /// comment itself, or nullptr in case there are no comments in \p File.
+ const std::map<unsigned, RawComment *> *getCommentsInFile(FileID File) const;
+
+ bool empty() const;
+
+ unsigned getCommentBeginLine(RawComment *C, FileID File,
+ unsigned Offset) const;
+ unsigned getCommentEndOffset(RawComment *C) const;
private:
SourceManager &SourceMgr;
- std::vector<RawComment *> Comments;
-
- void addDeserializedComments(ArrayRef<RawComment *> DeserializedComments);
+ // mapping: FileId -> comment begin offset -> comment
+ llvm::DenseMap<FileID, std::map<unsigned, RawComment *>> OrderedComments;
+ mutable llvm::DenseMap<RawComment *, unsigned> CommentBeginLine;
+ mutable llvm::DenseMap<RawComment *, unsigned> CommentEndOffset;
friend class ASTReader;
+ friend class ASTWriter;
};
} // end namespace clang