diff options
Diffstat (limited to 'lib/Format/UnwrappedLineParser.cpp')
-rw-r--r-- | lib/Format/UnwrappedLineParser.cpp | 24 |
1 files changed, 18 insertions, 6 deletions
diff --git a/lib/Format/UnwrappedLineParser.cpp b/lib/Format/UnwrappedLineParser.cpp index 78a1abdcf8..614125b943 100644 --- a/lib/Format/UnwrappedLineParser.cpp +++ b/lib/Format/UnwrappedLineParser.cpp @@ -80,13 +80,25 @@ bool UnwrappedLineParser::parseBlock(unsigned AddLevels) { } void UnwrappedLineParser::parsePPDirective() { - while (!eof()) { - nextToken(); - if (FormatTok.NewlinesBefore > 0) { - addUnwrappedLine(); - return; - } + assert(FormatTok.Tok.is(tok::hash) && "'#' expected"); + nextToken(); + + Line.InPPDirective = true; + if (FormatTok.Tok.getIdentifierInfo() == NULL) { + addUnwrappedLine(); + Line.InPPDirective = false; + return; } + + do { + if (FormatTok.NewlinesBefore > 0 && + FormatTok.HasUnescapedNewline) { + break; + } + nextToken(); + } while (!eof()); + addUnwrappedLine(); + Line.InPPDirective = false; } void UnwrappedLineParser::parseComments() { |