Allow us to better guess the context of an unwrapped line.

This gives us the ability to guess better defaults for whether a *
between identifiers is a pointer dereference or binary operator.

Now correctly formats:
void f(a *b);
void f() { f(a * b); }

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@173243 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Format/UnwrappedLineParser.h b/lib/Format/UnwrappedLineParser.h
index f48594d..1ab1ca2 100644
--- a/lib/Format/UnwrappedLineParser.h
+++ b/lib/Format/UnwrappedLineParser.h
@@ -84,7 +84,7 @@
 /// \c UnwrappedLineFormatter. The key property is that changing the formatting
 /// within an unwrapped line does not affect any other unwrapped lines.
 struct UnwrappedLine {
-  UnwrappedLine() : Level(0), InPPDirective(false) {
+  UnwrappedLine() : Level(0), InPPDirective(false), MustBeDeclaration(false) {
   }
 
   // FIXME: Don't use std::list here.
@@ -96,6 +96,8 @@
 
   /// \brief Whether this \c UnwrappedLine is part of a preprocessor directive.
   bool InPPDirective;
+
+  bool MustBeDeclaration;
 };
 
 class UnwrappedLineConsumer {
@@ -124,7 +126,7 @@
 private:
   bool parseFile();
   bool parseLevel(bool HasOpeningBrace);
-  bool parseBlock(unsigned AddLevels = 1);
+  bool parseBlock(bool MustBeDeclaration, unsigned AddLevels = 1);
   void parsePPDirective();
   void parsePPDefine();
   void parsePPUnknown();
@@ -180,6 +182,10 @@
   // \c &PreprocessorDirectives.
   std::vector<UnwrappedLine> *CurrentLines;
 
+  // We store for each line whether it must be a declaration depending on
+  // whether we are in a compound statement or not.
+  std::vector<bool> DeclarationScopeStack;
+
   clang::DiagnosticsEngine &Diag;
   const FormatStyle &Style;
   FormatTokenSource *Tokens;