djasper added inline comments.

================
Comment at: lib/Format/UnwrappedLineParser.cpp:2378
       ScopedLineState BlockState(*this, SwitchToPreprocessorLines);
+      if (InitialLevel)
+        Line->Level = *InitialLevel;
----------------
What happens if we always set the Level to 0 here?


================
Comment at: lib/Format/UnwrappedLineParser.cpp:489
 
-  nextToken(); // Munch the closing brace.
+  nextToken(InitialLevel); // Munch the closing brace.
 
----------------
krasimir wrote:
> djasper wrote:
> > What happens if you instead change the Line->Level = InitialLevel; 
> > statement from below to before this line? That seems like the more 
> > intuitively correct fix.
> This doesn't work since comments before the right brace haven't been emitted 
> yet and would get the wrong level.
So that means this seems to be the interesting case:

  void f() {
    DoSomething();
    // This was a fun function.
  }
  // Cool macro:
  #define A a

Now, both comments are basically read when we are reading the "}", but they 
should have different indentation levels. I have another suggestion, see below.


================
Comment at: unittests/Format/FormatTestComments.cpp:848
+            "}",
+            format("int f(int i) {\n"
+                   "  if (true) {\n"
----------------
krasimir wrote:
> djasper wrote:
> > Generally, mess up the code in some way to ensure that it is actually being 
> > formatted.
> Messing up doesn't work in this case, because we rely on the original columns 
> of the comment and the previous line. That's why I added a bunch of tests.
I meant *manually* mess up. So add spaces here and there.


https://reviews.llvm.org/D35485



_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to