aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorAlexander Kornienko <alexfh@google.com>2012-12-10 16:34:48 +0000
committerAlexander Kornienko <alexfh@google.com>2012-12-10 16:34:48 +0000
commit56e49c5cc2b05e805c7aa9dc53672711e540d58b (patch)
treefe9996f2d1929ef7b63dbb625c4ff98ad217e85a /lib
parent31bdf071afc18bb9551e4f4254be297333200c4a (diff)
Clang-format: error recovery for access specifiers
Reviewers: klimek Reviewed By: klimek CC: cfe-commits Differential Revision: http://llvm-reviews.chandlerc.com/D198 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@169738 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r--lib/Format/Format.cpp5
-rw-r--r--lib/Format/UnwrappedLineParser.cpp4
2 files changed, 6 insertions, 3 deletions
diff --git a/lib/Format/Format.cpp b/lib/Format/Format.cpp
index 3bedc6a4cd..7f1131ca6f 100644
--- a/lib/Format/Format.cpp
+++ b/lib/Format/Format.cpp
@@ -371,8 +371,9 @@ private:
if (Newlines == 0 && Offset != 0)
Newlines = 1;
unsigned Indent = Line.Level * 2;
- if (Token.Tok.is(tok::kw_public) || Token.Tok.is(tok::kw_protected) ||
- Token.Tok.is(tok::kw_private))
+ if ((Token.Tok.is(tok::kw_public) || Token.Tok.is(tok::kw_protected) ||
+ Token.Tok.is(tok::kw_private)) &&
+ static_cast<int>(Indent) + Style.AccessModifierOffset >= 0)
Indent += Style.AccessModifierOffset;
replaceWhitespace(Token, Newlines, Indent);
return Indent;
diff --git a/lib/Format/UnwrappedLineParser.cpp b/lib/Format/UnwrappedLineParser.cpp
index a225f3b3e7..8545f336b8 100644
--- a/lib/Format/UnwrappedLineParser.cpp
+++ b/lib/Format/UnwrappedLineParser.cpp
@@ -311,7 +311,9 @@ void UnwrappedLineParser::parseSwitch() {
void UnwrappedLineParser::parseAccessSpecifier() {
nextToken();
- nextToken();
+ // Otherwise, we don't know what it is, and we'd better keep the next token.
+ if (FormatTok.Tok.is(tok::colon))
+ nextToken();
addUnwrappedLine();
}