summaryrefslogtreecommitdiffstats
path: root/clang/lib/Format
diff options
context:
space:
mode:
Diffstat (limited to 'clang/lib/Format')
-rw-r--r--clang/lib/Format/Format.cpp5
-rw-r--r--clang/lib/Format/UnwrappedLineParser.cpp4
2 files changed, 6 insertions, 3 deletions
diff --git a/clang/lib/Format/Format.cpp b/clang/lib/Format/Format.cpp
index 3bedc6a4cd5..7f1131ca6f5 100644
--- a/clang/lib/Format/Format.cpp
+++ b/clang/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/clang/lib/Format/UnwrappedLineParser.cpp b/clang/lib/Format/UnwrappedLineParser.cpp
index a225f3b3e78..8545f336b86 100644
--- a/clang/lib/Format/UnwrappedLineParser.cpp
+++ b/clang/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();
}
OpenPOWER on IntegriCloud