diff options
author | Dmitri Gribenko <gribozavr@gmail.com> | 2012-06-20 00:34:58 +0000 |
---|---|---|
committer | Dmitri Gribenko <gribozavr@gmail.com> | 2012-06-20 00:34:58 +0000 |
commit | aa0cd85838f2a024e589ea4e8c2094130065af21 (patch) | |
tree | b4e013c1268210fa0769c263d702c637395b59ae /lib/Serialization/ASTWriter.cpp | |
parent | ed36b2a80878c29603bdc89a7969253fb6446174 (diff) |
Structured comment parsing, first step.
* Retain comments in the AST
* Serialize/deserialize comments
* Find comments attached to a certain Decl
* Expose raw comment text and SourceRange via libclang
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@158771 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Serialization/ASTWriter.cpp')
-rw-r--r-- | lib/Serialization/ASTWriter.cpp | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/lib/Serialization/ASTWriter.cpp b/lib/Serialization/ASTWriter.cpp index de5816df9e..1f96180507 100644 --- a/lib/Serialization/ASTWriter.cpp +++ b/lib/Serialization/ASTWriter.cpp @@ -2240,6 +2240,23 @@ void ASTWriter::WriteFileDeclIDsMap() { Stream.EmitRecordWithBlob(AbbrevCode, Record, data(FileSortedIDs)); } +void ASTWriter::WriteComments() { + Stream.EnterSubblock(COMMENTS_BLOCK_ID, 3); + ArrayRef<RawComment> RawComments = Context->Comments.getComments(); + RecordData Record; + for (ArrayRef<RawComment>::iterator I = RawComments.begin(), + E = RawComments.end(); + I != E; ++I) { + Record.clear(); + AddSourceRange(I->getSourceRange(), Record); + Record.push_back(I->getKind()); + Record.push_back(I->isTrailingComment()); + Record.push_back(I->isAlmostTrailingComment()); + Stream.EmitRecord(COMMENTS_RAW_COMMENT, Record); + } + Stream.ExitBlock(); +} + //===----------------------------------------------------------------------===// // Global Method Pool and Selector Serialization //===----------------------------------------------------------------------===// @@ -3415,6 +3432,7 @@ void ASTWriter::WriteASTCore(Sema &SemaRef, MemorizeStatCalls *StatCalls, WriteFileDeclIDsMap(); WriteSourceManagerBlock(Context.getSourceManager(), PP, isysroot); + WriteComments(); if (Chain) { // Write the mapping information describing our module dependencies and how |