From 952eddef9aff85b1e92626e89baaf7a360e2ac85 Mon Sep 17 00:00:00 2001 From: dim Date: Sun, 22 Dec 2013 00:07:40 +0000 Subject: Vendor import of clang release_34 branch r197841 (effectively, 3.4 RC3): https://llvm.org/svn/llvm-project/cfe/branches/release_34@197841 --- lib/AST/CommentParser.cpp | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'lib/AST/CommentParser.cpp') diff --git a/lib/AST/CommentParser.cpp b/lib/AST/CommentParser.cpp index d89c79b..03e0101 100644 --- a/lib/AST/CommentParser.cpp +++ b/lib/AST/CommentParser.cpp @@ -16,6 +16,15 @@ #include "llvm/Support/ErrorHandling.h" namespace clang { + +static inline bool isWhitespace(llvm::StringRef S) { + for (StringRef::const_iterator I = S.begin(), E = S.end(); I != E; ++I) { + if (!isWhitespace(*I)) + return false; + } + return true; +} + namespace comments { /// Re-lexes a sequence of tok::text tokens. @@ -594,6 +603,18 @@ BlockContentComment *Parser::parseParagraphOrBlockCommand() { consumeToken(); break; // Two newlines -- end of paragraph. } + // Also allow [tok::newline, tok::text, tok::newline] if the middle + // tok::text is just whitespace. + if (Tok.is(tok::text) && isWhitespace(Tok.getText())) { + Token WhitespaceTok = Tok; + consumeToken(); + if (Tok.is(tok::newline) || Tok.is(tok::eof)) { + consumeToken(); + break; + } + // We have [tok::newline, tok::text, non-newline]. Put back tok::text. + putBack(WhitespaceTok); + } if (Content.size() > 0) Content.back()->addTrailingNewline(); continue; -- cgit v1.1