diff options
| author | Nico Weber <nicolasweber@gmx.de> | 2013-01-07 19:05:19 +0000 |
|---|---|---|
| committer | Nico Weber <nicolasweber@gmx.de> | 2013-01-07 19:05:19 +0000 |
| commit | 04e9f1ab420486664622e5b1a71b8b7cfba20327 (patch) | |
| tree | 1f727403f0d474770c57737ff010ec48bb15214e /clang/lib | |
| parent | e8f1eaea8ac513530fd7ce4c2f0d46cc77f9e540 (diff) | |
| download | bcm5719-llvm-04e9f1ab420486664622e5b1a71b8b7cfba20327.tar.gz bcm5719-llvm-04e9f1ab420486664622e5b1a71b8b7cfba20327.zip | |
Formatter: Support @public/@protected/@package/@private.
@package is an Objective-C 2 feature, so turn on ObjC2 as well.
llvm-svn: 171766
Diffstat (limited to 'clang/lib')
| -rw-r--r-- | clang/lib/Format/Format.cpp | 15 | ||||
| -rw-r--r-- | clang/lib/Format/UnwrappedLineParser.cpp | 12 |
2 files changed, 25 insertions, 2 deletions
diff --git a/clang/lib/Format/Format.cpp b/clang/lib/Format/Format.cpp index 7a6b6e2081b..5c433834c84 100644 --- a/clang/lib/Format/Format.cpp +++ b/clang/lib/Format/Format.cpp @@ -510,8 +510,19 @@ private: if (Newlines == 0 && !Token.IsFirst) 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)) && + + bool IsAccessModifier = false; + if (Token.Tok.is(tok::kw_public) || Token.Tok.is(tok::kw_protected) || + Token.Tok.is(tok::kw_private)) + IsAccessModifier = true; + else if (Token.Tok.is(tok::at) && Line.Tokens.size() > 1 && + (Line.Tokens[1].Tok.isObjCAtKeyword(tok::objc_public) || + Line.Tokens[1].Tok.isObjCAtKeyword(tok::objc_protected) || + Line.Tokens[1].Tok.isObjCAtKeyword(tok::objc_package) || + Line.Tokens[1].Tok.isObjCAtKeyword(tok::objc_private))) + IsAccessModifier = true; + + if (IsAccessModifier && static_cast<int>(Indent) + Style.AccessModifierOffset >= 0) Indent += Style.AccessModifierOffset; if (!Line.InPPDirective || Token.HasUnescapedNewline) diff --git a/clang/lib/Format/UnwrappedLineParser.cpp b/clang/lib/Format/UnwrappedLineParser.cpp index d7220259b7e..adb536324a3 100644 --- a/clang/lib/Format/UnwrappedLineParser.cpp +++ b/clang/lib/Format/UnwrappedLineParser.cpp @@ -198,6 +198,18 @@ void UnwrappedLineParser::parseStructuralElement() { int TokenNumber = 0; switch (FormatTok.Tok.getKind()) { + case tok::at: + nextToken(); + switch (FormatTok.Tok.getObjCKeywordID()) { + case tok::objc_public: + case tok::objc_protected: + case tok::objc_package: + case tok::objc_private: + return parseAccessSpecifier(); + default: + break; + } + break; case tok::kw_namespace: parseNamespace(); return; |

