Fixes use of unescaped newlines when formatting preprocessor directives.

This is the first step towards handling preprocessor directives. This
patch only fixes the most pressing issue, namely correctly escaping
newlines for tokens within a sequence of a preprocessor directive.

The next step will be to fix incorrect format decisions on #define
directives.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@171393 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Format/UnwrappedLineParser.cpp b/lib/Format/UnwrappedLineParser.cpp
index 78a1abd..614125b 100644
--- a/lib/Format/UnwrappedLineParser.cpp
+++ b/lib/Format/UnwrappedLineParser.cpp
@@ -80,13 +80,25 @@
 }
 
 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() {