diff options
author | Manuel Klimek <klimek@google.com> | 2013-01-23 14:08:21 +0000 |
---|---|---|
committer | Manuel Klimek <klimek@google.com> | 2013-01-23 14:08:21 +0000 |
commit | c1237a8b8fb71bace4af3fcd7da91c41cbf107c6 (patch) | |
tree | 8a6dbce35217aaad97c5fce8383c72f27f0848e8 /clang/lib/Format | |
parent | 7206a145dd83c3c39706c9a6c3581ae57d4c3630 (diff) | |
download | bcm5719-llvm-c1237a8b8fb71bace4af3fcd7da91c41cbf107c6.tar.gz bcm5719-llvm-c1237a8b8fb71bace4af3fcd7da91c41cbf107c6.zip |
Fixes layouting regression and invalid-read.
Layouting would prevent breaking before + in
a[b + c] = d;
Regression detected by code review.
Also fixes an invalid-read found by the valgrind bot.
llvm-svn: 173262
Diffstat (limited to 'clang/lib/Format')
-rw-r--r-- | clang/lib/Format/Format.cpp | 4 | ||||
-rw-r--r-- | clang/lib/Format/UnwrappedLineParser.cpp | 5 |
2 files changed, 7 insertions, 2 deletions
diff --git a/clang/lib/Format/Format.cpp b/clang/lib/Format/Format.cpp index d95deb57046..2952067c398 100644 --- a/clang/lib/Format/Format.cpp +++ b/clang/lib/Format/Format.cpp @@ -1256,8 +1256,10 @@ private: IsExpression = true; AnnotatedToken *Previous = Current.Parent; while (Previous != NULL) { - if (Previous->Type == TT_BinaryOperator) + if (Previous->Type == TT_BinaryOperator && + (Previous->is(tok::star) || Previous->is(tok::amp))) { Previous->Type = TT_PointerOrReference; + } Previous = Previous->Parent; } } diff --git a/clang/lib/Format/UnwrappedLineParser.cpp b/clang/lib/Format/UnwrappedLineParser.cpp index c21fa0d74e5..1b39442610f 100644 --- a/clang/lib/Format/UnwrappedLineParser.cpp +++ b/clang/lib/Format/UnwrappedLineParser.cpp @@ -38,7 +38,10 @@ public: } ~ScopedDeclarationState() { Stack.pop_back(); - Line.MustBeDeclaration = Stack.back(); + if (!Stack.empty()) + Line.MustBeDeclaration = Stack.back(); + else + Line.MustBeDeclaration = true; } private: UnwrappedLine &Line; |