[cfe-commits] r173250 - in /cfe/trunk: lib/Format/UnwrappedLineParser.cpp unittests/Format/FormatTest.cpp

Manuel Klimek klimek at google.com
Wed Jan 23 03:03:04 PST 2013


Author: klimek
Date: Wed Jan 23 05:03:04 2013
New Revision: 173250

URL: http://llvm.org/viewvc/llvm-project?rev=173250&view=rev
Log:
Fixes incorrect handling of the declaration context stack.

Modified:
    cfe/trunk/lib/Format/UnwrappedLineParser.cpp
    cfe/trunk/unittests/Format/FormatTest.cpp

Modified: cfe/trunk/lib/Format/UnwrappedLineParser.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/UnwrappedLineParser.cpp?rev=173250&r1=173249&r2=173250&view=diff
==============================================================================
--- cfe/trunk/lib/Format/UnwrappedLineParser.cpp (original)
+++ cfe/trunk/lib/Format/UnwrappedLineParser.cpp Wed Jan 23 05:03:04 2013
@@ -33,12 +33,12 @@
   ScopedDeclarationState(UnwrappedLine &Line, std::vector<bool> &Stack,
                          bool MustBeDeclaration)
       : Line(Line), Stack(Stack) {
-    Stack.push_back(MustBeDeclaration);
     Line.MustBeDeclaration = MustBeDeclaration;
+    Stack.push_back(MustBeDeclaration);
   }
   ~ScopedDeclarationState() {
-    Line.MustBeDeclaration = Stack.back();
     Stack.pop_back();
+    Line.MustBeDeclaration = Stack.back();
   }
 private:
   UnwrappedLine &Line;

Modified: cfe/trunk/unittests/Format/FormatTest.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTest.cpp?rev=173250&r1=173249&r2=173250&view=diff
==============================================================================
--- cfe/trunk/unittests/Format/FormatTest.cpp (original)
+++ cfe/trunk/unittests/Format/FormatTest.cpp Wed Jan 23 05:03:04 2013
@@ -1682,6 +1682,16 @@
 TEST_F(FormatTest, FormatStarDependingOnContext) {
   verifyFormat("void f(int *a);");
   verifyFormat("void f() { f(fint * b); }");
+  verifyFormat("class A {\n  void f(int *a);\n};");
+  verifyFormat("class A {\n  int *a;\n};");
+  verifyFormat("namespace a {\n"
+               "namespace b {\n"
+               "class A {\n"
+               "  void f() {}\n"
+               "  int *a;\n"
+               "};\n"
+               "}\n"
+               "}");
 }
 
 TEST_F(FormatTest, SpecialTokensAtEndOfLine) {





More information about the cfe-commits mailing list