summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--clang/lib/Format/FormatToken.h6
-rw-r--r--clang/lib/Format/UnwrappedLineParser.cpp3
-rw-r--r--clang/unittests/Format/FormatTest.cpp15
3 files changed, 23 insertions, 1 deletions
diff --git a/clang/lib/Format/FormatToken.h b/clang/lib/Format/FormatToken.h
index 11c4925d010..df474210122 100644
--- a/clang/lib/Format/FormatToken.h
+++ b/clang/lib/Format/FormatToken.h
@@ -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;
diff --git a/clang/lib/Format/UnwrappedLineParser.cpp b/clang/lib/Format/UnwrappedLineParser.cpp
index 21f0e7bad1b..d0c899ffe0b 100644
--- a/clang/lib/Format/UnwrappedLineParser.cpp
+++ b/clang/lib/Format/UnwrappedLineParser.cpp
@@ -747,7 +747,8 @@ void UnwrappedLineParser::parseStructuralElement() {
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:
diff --git a/clang/unittests/Format/FormatTest.cpp b/clang/unittests/Format/FormatTest.cpp
index 6481a3122f6..cf2d8097f7b 100644
--- a/clang/unittests/Format/FormatTest.cpp
+++ b/clang/unittests/Format/FormatTest.cpp
@@ -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) {
OpenPOWER on IntegriCloud