From: Manuel Klimek Date: Wed, 23 Jan 2013 11:03:04 +0000 (+0000) Subject: Fixes incorrect handling of the declaration context stack. X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=390805731f9a8336bffa39bc237284570b12448b;p=platform%2Fupstream%2Fllvm.git Fixes incorrect handling of the declaration context stack. llvm-svn: 173250 --- diff --git a/clang/lib/Format/UnwrappedLineParser.cpp b/clang/lib/Format/UnwrappedLineParser.cpp index 0470741..c21fa0d 100644 --- a/clang/lib/Format/UnwrappedLineParser.cpp +++ b/clang/lib/Format/UnwrappedLineParser.cpp @@ -33,12 +33,12 @@ public: ScopedDeclarationState(UnwrappedLine &Line, std::vector &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; diff --git a/clang/unittests/Format/FormatTest.cpp b/clang/unittests/Format/FormatTest.cpp index fb5221e..114359d 100644 --- a/clang/unittests/Format/FormatTest.cpp +++ b/clang/unittests/Format/FormatTest.cpp @@ -1682,6 +1682,16 @@ TEST_F(FormatTest, BlockComments) { 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) {