aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorDmitri Gribenko <gribozavr@gmail.com>2013-04-26 20:12:49 +0000
committerDmitri Gribenko <gribozavr@gmail.com>2013-04-26 20:12:49 +0000
commit002f9281e010202b87cc120195b67df06ef3e17f (patch)
tree06d46ba00c48f8225284312cb7f1d41423580a59 /lib
parenta2c3646c35dd09d21b74826240aa916545b1873f (diff)
Comment parsing: -fparse-all-comments: recognize empty line comments
In -fparse-all-comments mode empty '//' comments were recognized as RCK_Invalid, and were not merged with next and previous lines. Patch by Amin Shali. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@180625 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r--lib/AST/RawCommentList.cpp8
1 files changed, 5 insertions, 3 deletions
diff --git a/lib/AST/RawCommentList.cpp b/lib/AST/RawCommentList.cpp
index 7816459380..fb85c142e3 100644
--- a/lib/AST/RawCommentList.cpp
+++ b/lib/AST/RawCommentList.cpp
@@ -21,8 +21,10 @@ using namespace clang;
namespace {
/// Get comment kind and bool describing if it is a trailing comment.
-std::pair<RawComment::CommentKind, bool> getCommentKind(StringRef Comment) {
- if (Comment.size() < 3 || Comment[0] != '/')
+std::pair<RawComment::CommentKind, bool> getCommentKind(StringRef Comment,
+ bool ParseAllComments) {
+ const size_t MinCommentLength = ParseAllComments ? 2 : 3;
+ if ((Comment.size() < MinCommentLength) || Comment[0] != '/')
return std::make_pair(RawComment::RCK_Invalid, false);
RawComment::CommentKind K;
@@ -76,7 +78,7 @@ RawComment::RawComment(const SourceManager &SourceMgr, SourceRange SR,
if (!Merged) {
// Guess comment kind.
- std::pair<CommentKind, bool> K = getCommentKind(RawText);
+ std::pair<CommentKind, bool> K = getCommentKind(RawText, ParseAllComments);
Kind = K.first;
IsTrailingComment = K.second;