r223458 - clang-format: Support NS_OPTIONS, CF_ENUM and CF_OPTIONS.
Daniel Jasper
djasper at google.com
Fri Dec 5 02:42:21 PST 2014
Author: djasper
Date: Fri Dec 5 04:42:21 2014
New Revision: 223458
URL: http://llvm.org/viewvc/llvm-project?rev=223458&view=rev
Log:
clang-format: Support NS_OPTIONS, CF_ENUM and CF_OPTIONS.
This fixes llvm.org/PR21756.
Modified:
cfe/trunk/lib/Format/FormatToken.h
cfe/trunk/lib/Format/UnwrappedLineParser.cpp
cfe/trunk/unittests/Format/FormatTest.cpp
Modified: cfe/trunk/lib/Format/FormatToken.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/FormatToken.h?rev=223458&r1=223457&r2=223458&view=diff
==============================================================================
--- cfe/trunk/lib/Format/FormatToken.h (original)
+++ cfe/trunk/lib/Format/FormatToken.h Fri Dec 5 04:42:21 2014
@@ -535,7 +535,10 @@ private:
struct AdditionalKeywords {
AdditionalKeywords(IdentifierTable &IdentTable) {
kw_in = &IdentTable.get("in");
+ kw_CF_ENUM = &IdentTable.get("CF_ENUM");
+ kw_CF_OPTIONS = &IdentTable.get("CF_OPTIONS");
kw_NS_ENUM = &IdentTable.get("NS_ENUM");
+ kw_NS_OPTIONS = &IdentTable.get("NS_OPTIONS");
kw_finally = &IdentTable.get("finally");
kw_function = &IdentTable.get("function");
@@ -560,7 +563,10 @@ struct AdditionalKeywords {
// ObjC context sensitive keywords.
IdentifierInfo *kw_in;
+ IdentifierInfo *kw_CF_ENUM;
+ IdentifierInfo *kw_CF_OPTIONS;
IdentifierInfo *kw_NS_ENUM;
+ IdentifierInfo *kw_NS_OPTIONS;
// JavaScript keywords.
IdentifierInfo *kw_finally;
Modified: cfe/trunk/lib/Format/UnwrappedLineParser.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/UnwrappedLineParser.cpp?rev=223458&r1=223457&r2=223458&view=diff
==============================================================================
--- cfe/trunk/lib/Format/UnwrappedLineParser.cpp (original)
+++ cfe/trunk/lib/Format/UnwrappedLineParser.cpp Fri Dec 5 04:42:21 2014
@@ -747,7 +747,8 @@ void UnwrappedLineParser::parseStructura
break;
case tok::kw_typedef:
nextToken();
- if (FormatTok->is(Keywords.kw_NS_ENUM))
+ if (FormatTok->isOneOf(Keywords.kw_NS_ENUM, Keywords.kw_NS_OPTIONS,
+ Keywords.kw_CF_ENUM, Keywords.kw_CF_OPTIONS))
parseEnum();
break;
case tok::kw_struct:
Modified: cfe/trunk/unittests/Format/FormatTest.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTest.cpp?rev=223458&r1=223457&r2=223458&view=diff
==============================================================================
--- cfe/trunk/unittests/Format/FormatTest.cpp (original)
+++ cfe/trunk/unittests/Format/FormatTest.cpp Fri Dec 5 04:42:21 2014
@@ -2069,6 +2069,21 @@ TEST_F(FormatTest, FormatsNSEnums) {
" // Information about aThirdDecentlyLongValue.\n"
" aThirdDecentlyLongValue\n"
"};");
+ verifyGoogleFormat("typedef NS_OPTIONS(NSInteger, MyType) {\n"
+ " a = 1,\n"
+ " b = 2,\n"
+ " c = 3,\n"
+ "};");
+ verifyGoogleFormat("typedef CF_ENUM(NSInteger, MyType) {\n"
+ " a = 1,\n"
+ " b = 2,\n"
+ " c = 3,\n"
+ "};");
+ verifyGoogleFormat("typedef CF_OPTIONS(NSInteger, MyType) {\n"
+ " a = 1,\n"
+ " b = 2,\n"
+ " c = 3,\n"
+ "};");
}
TEST_F(FormatTest, FormatsBitfields) {
More information about the cfe-commits
mailing list