[PATCH] D147577: [Format/ObjC] Support NS_ERROR_ENUM in ObjC language guesser

2023-04-07 Thread Ben Hamilton via Phabricator via cfe-commits
benhamilton added a subscriber: goncharov.
benhamilton added a comment.

In D147577#4252225 , @MyDeveloperDay 
wrote:

> The build machines aren’t using a latest enough version of clang-format for 
> our local .clang-format file

Thanks, that's what I figured. I assigned 
https://github.com/llvm/llvm-project/issues/62007 to @goncharov for now.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D147577/new/

https://reviews.llvm.org/D147577

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D147577: [Format/ObjC] Support NS_ERROR_ENUM in ObjC language guesser

2023-04-07 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay added a comment.

The build machines aren’t using a latest enough version of clang-format for our 
local .clang-format file


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D147577/new/

https://reviews.llvm.org/D147577

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D147577: [Format/ObjC] Support NS_ERROR_ENUM in ObjC language guesser

2023-04-07 Thread Ben Hamilton via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG00ea6798959d: [Format/ObjC] Support NS_ERROR_ENUM in ObjC 
language guesser (authored by benhamilton).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D147577/new/

https://reviews.llvm.org/D147577

Files:
  clang/lib/Format/Format.cpp
  clang/lib/Format/FormatToken.h
  clang/unittests/Format/FormatTestObjC.cpp


Index: clang/unittests/Format/FormatTestObjC.cpp
===
--- clang/unittests/Format/FormatTestObjC.cpp
+++ clang/unittests/Format/FormatTestObjC.cpp
@@ -89,6 +89,11 @@
   ASSERT_TRUE((bool)Style);
   EXPECT_EQ(FormatStyle::LK_ObjC, Style->Language);
 
+  Style =
+  getStyle("{}", "a.h", "none", "typedef NS_ERROR_ENUM(int, Foo) {};\n");
+  ASSERT_TRUE((bool)Style);
+  EXPECT_EQ(FormatStyle::LK_ObjC, Style->Language);
+
   Style = getStyle("{}", "a.h", "none", "enum Foo {};");
   ASSERT_TRUE((bool)Style);
   EXPECT_EQ(FormatStyle::LK_Cpp, Style->Language);
Index: clang/lib/Format/FormatToken.h
===
--- clang/lib/Format/FormatToken.h
+++ clang/lib/Format/FormatToken.h
@@ -949,6 +949,7 @@
 kw_CF_OPTIONS = &IdentTable.get("CF_OPTIONS");
 kw_NS_CLOSED_ENUM = &IdentTable.get("NS_CLOSED_ENUM");
 kw_NS_ENUM = &IdentTable.get("NS_ENUM");
+kw_NS_ERROR_ENUM = &IdentTable.get("NS_ERROR_ENUM");
 kw_NS_OPTIONS = &IdentTable.get("NS_OPTIONS");
 
 kw_as = &IdentTable.get("as");
@@ -1334,6 +1335,7 @@
   IdentifierInfo *kw_CF_OPTIONS;
   IdentifierInfo *kw_NS_CLOSED_ENUM;
   IdentifierInfo *kw_NS_ENUM;
+  IdentifierInfo *kw_NS_ERROR_ENUM;
   IdentifierInfo *kw_NS_OPTIONS;
   IdentifierInfo *kw___except;
   IdentifierInfo *kw___has_include;
Index: clang/lib/Format/Format.cpp
===
--- clang/lib/Format/Format.cpp
+++ clang/lib/Format/Format.cpp
@@ -2699,6 +2699,8 @@
 "NSDecimalNumber",
 "NSDictionary",
 "NSEdgeInsets",
+"NSError",
+"NSErrorDomain",
 "NSHashTable",
 "NSIndexPath",
 "NSIndexSet",
@@ -2760,6 +2762,7 @@
 FormatTok->TokenText)) ||
 FormatTok->is(TT_ObjCStringLiteral) ||
 FormatTok->isOneOf(Keywords.kw_NS_CLOSED_ENUM, Keywords.kw_NS_ENUM,
+   Keywords.kw_NS_ERROR_ENUM,
Keywords.kw_NS_OPTIONS, TT_ObjCBlockLBrace,
TT_ObjCBlockLParen, TT_ObjCDecl, TT_ObjCForIn,
TT_ObjCMethodExpr, TT_ObjCMethodSpecifier,


Index: clang/unittests/Format/FormatTestObjC.cpp
===
--- clang/unittests/Format/FormatTestObjC.cpp
+++ clang/unittests/Format/FormatTestObjC.cpp
@@ -89,6 +89,11 @@
   ASSERT_TRUE((bool)Style);
   EXPECT_EQ(FormatStyle::LK_ObjC, Style->Language);
 
+  Style =
+  getStyle("{}", "a.h", "none", "typedef NS_ERROR_ENUM(int, Foo) {};\n");
+  ASSERT_TRUE((bool)Style);
+  EXPECT_EQ(FormatStyle::LK_ObjC, Style->Language);
+
   Style = getStyle("{}", "a.h", "none", "enum Foo {};");
   ASSERT_TRUE((bool)Style);
   EXPECT_EQ(FormatStyle::LK_Cpp, Style->Language);
Index: clang/lib/Format/FormatToken.h
===
--- clang/lib/Format/FormatToken.h
+++ clang/lib/Format/FormatToken.h
@@ -949,6 +949,7 @@
 kw_CF_OPTIONS = &IdentTable.get("CF_OPTIONS");
 kw_NS_CLOSED_ENUM = &IdentTable.get("NS_CLOSED_ENUM");
 kw_NS_ENUM = &IdentTable.get("NS_ENUM");
+kw_NS_ERROR_ENUM = &IdentTable.get("NS_ERROR_ENUM");
 kw_NS_OPTIONS = &IdentTable.get("NS_OPTIONS");
 
 kw_as = &IdentTable.get("as");
@@ -1334,6 +1335,7 @@
   IdentifierInfo *kw_CF_OPTIONS;
   IdentifierInfo *kw_NS_CLOSED_ENUM;
   IdentifierInfo *kw_NS_ENUM;
+  IdentifierInfo *kw_NS_ERROR_ENUM;
   IdentifierInfo *kw_NS_OPTIONS;
   IdentifierInfo *kw___except;
   IdentifierInfo *kw___has_include;
Index: clang/lib/Format/Format.cpp
===
--- clang/lib/Format/Format.cpp
+++ clang/lib/Format/Format.cpp
@@ -2699,6 +2699,8 @@
 "NSDecimalNumber",
 "NSDictionary",
 "NSEdgeInsets",
+"NSError",
+"NSErrorDomain",
 "NSHashTable",
 "NSIndexPath",
 "NSIndexSet",
@@ -2760,6 +2762,7 @@
 FormatTok->TokenText)) ||
 FormatTok->is(TT_ObjCStringLiteral) ||
 FormatTok->isOneOf(Keywords.kw_NS_CLOSED_ENUM, Keywords.kw_NS_ENUM,
+   Keywords.kw_NS_ERROR_ENUM,
Keywords.kw_NS_OPTIONS, TT_ObjCBlockLBrace,
TT_ObjCBlockLParen, TT_ObjCDecl, TT_ObjCForIn,
 

[PATCH] D147577: [Format/ObjC] Support NS_ERROR_ENUM in ObjC language guesser

2023-04-07 Thread Ben Hamilton via Phabricator via cfe-commits
benhamilton added a comment.

Filed https://github.com/llvm/llvm-project/issues/62007 on the buildkite 
failure (despite it being in `git-clang-format`, I'm about 98% sure it's 
unrelated).


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D147577/new/

https://reviews.llvm.org/D147577

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D147577: [Format/ObjC] Support NS_ERROR_ENUM in ObjC language guesser

2023-04-06 Thread Ben Hamilton via Phabricator via cfe-commits
benhamilton updated this revision to Diff 511539.
benhamilton added a comment.

Rebasing.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D147577/new/

https://reviews.llvm.org/D147577

Files:
  clang/lib/Format/Format.cpp
  clang/lib/Format/FormatToken.h
  clang/unittests/Format/FormatTestObjC.cpp


Index: clang/unittests/Format/FormatTestObjC.cpp
===
--- clang/unittests/Format/FormatTestObjC.cpp
+++ clang/unittests/Format/FormatTestObjC.cpp
@@ -89,6 +89,11 @@
   ASSERT_TRUE((bool)Style);
   EXPECT_EQ(FormatStyle::LK_ObjC, Style->Language);
 
+  Style =
+  getStyle("{}", "a.h", "none", "typedef NS_ERROR_ENUM(int, Foo) {};\n");
+  ASSERT_TRUE((bool)Style);
+  EXPECT_EQ(FormatStyle::LK_ObjC, Style->Language);
+
   Style = getStyle("{}", "a.h", "none", "enum Foo {};");
   ASSERT_TRUE((bool)Style);
   EXPECT_EQ(FormatStyle::LK_Cpp, Style->Language);
Index: clang/lib/Format/FormatToken.h
===
--- clang/lib/Format/FormatToken.h
+++ clang/lib/Format/FormatToken.h
@@ -949,6 +949,7 @@
 kw_CF_OPTIONS = &IdentTable.get("CF_OPTIONS");
 kw_NS_CLOSED_ENUM = &IdentTable.get("NS_CLOSED_ENUM");
 kw_NS_ENUM = &IdentTable.get("NS_ENUM");
+kw_NS_ERROR_ENUM = &IdentTable.get("NS_ERROR_ENUM");
 kw_NS_OPTIONS = &IdentTable.get("NS_OPTIONS");
 
 kw_as = &IdentTable.get("as");
@@ -1334,6 +1335,7 @@
   IdentifierInfo *kw_CF_OPTIONS;
   IdentifierInfo *kw_NS_CLOSED_ENUM;
   IdentifierInfo *kw_NS_ENUM;
+  IdentifierInfo *kw_NS_ERROR_ENUM;
   IdentifierInfo *kw_NS_OPTIONS;
   IdentifierInfo *kw___except;
   IdentifierInfo *kw___has_include;
Index: clang/lib/Format/Format.cpp
===
--- clang/lib/Format/Format.cpp
+++ clang/lib/Format/Format.cpp
@@ -2699,6 +2699,8 @@
 "NSDecimalNumber",
 "NSDictionary",
 "NSEdgeInsets",
+"NSError",
+"NSErrorDomain",
 "NSHashTable",
 "NSIndexPath",
 "NSIndexSet",
@@ -2760,6 +2762,7 @@
 FormatTok->TokenText)) ||
 FormatTok->is(TT_ObjCStringLiteral) ||
 FormatTok->isOneOf(Keywords.kw_NS_CLOSED_ENUM, Keywords.kw_NS_ENUM,
+   Keywords.kw_NS_ERROR_ENUM,
Keywords.kw_NS_OPTIONS, TT_ObjCBlockLBrace,
TT_ObjCBlockLParen, TT_ObjCDecl, TT_ObjCForIn,
TT_ObjCMethodExpr, TT_ObjCMethodSpecifier,


Index: clang/unittests/Format/FormatTestObjC.cpp
===
--- clang/unittests/Format/FormatTestObjC.cpp
+++ clang/unittests/Format/FormatTestObjC.cpp
@@ -89,6 +89,11 @@
   ASSERT_TRUE((bool)Style);
   EXPECT_EQ(FormatStyle::LK_ObjC, Style->Language);
 
+  Style =
+  getStyle("{}", "a.h", "none", "typedef NS_ERROR_ENUM(int, Foo) {};\n");
+  ASSERT_TRUE((bool)Style);
+  EXPECT_EQ(FormatStyle::LK_ObjC, Style->Language);
+
   Style = getStyle("{}", "a.h", "none", "enum Foo {};");
   ASSERT_TRUE((bool)Style);
   EXPECT_EQ(FormatStyle::LK_Cpp, Style->Language);
Index: clang/lib/Format/FormatToken.h
===
--- clang/lib/Format/FormatToken.h
+++ clang/lib/Format/FormatToken.h
@@ -949,6 +949,7 @@
 kw_CF_OPTIONS = &IdentTable.get("CF_OPTIONS");
 kw_NS_CLOSED_ENUM = &IdentTable.get("NS_CLOSED_ENUM");
 kw_NS_ENUM = &IdentTable.get("NS_ENUM");
+kw_NS_ERROR_ENUM = &IdentTable.get("NS_ERROR_ENUM");
 kw_NS_OPTIONS = &IdentTable.get("NS_OPTIONS");
 
 kw_as = &IdentTable.get("as");
@@ -1334,6 +1335,7 @@
   IdentifierInfo *kw_CF_OPTIONS;
   IdentifierInfo *kw_NS_CLOSED_ENUM;
   IdentifierInfo *kw_NS_ENUM;
+  IdentifierInfo *kw_NS_ERROR_ENUM;
   IdentifierInfo *kw_NS_OPTIONS;
   IdentifierInfo *kw___except;
   IdentifierInfo *kw___has_include;
Index: clang/lib/Format/Format.cpp
===
--- clang/lib/Format/Format.cpp
+++ clang/lib/Format/Format.cpp
@@ -2699,6 +2699,8 @@
 "NSDecimalNumber",
 "NSDictionary",
 "NSEdgeInsets",
+"NSError",
+"NSErrorDomain",
 "NSHashTable",
 "NSIndexPath",
 "NSIndexSet",
@@ -2760,6 +2762,7 @@
 FormatTok->TokenText)) ||
 FormatTok->is(TT_ObjCStringLiteral) ||
 FormatTok->isOneOf(Keywords.kw_NS_CLOSED_ENUM, Keywords.kw_NS_ENUM,
+   Keywords.kw_NS_ERROR_ENUM,
Keywords.kw_NS_OPTIONS, TT_ObjCBlockLBrace,
TT_ObjCBlockLParen, TT_ObjCDecl, TT_ObjCForIn,
TT_ObjCMethodExpr, TT_ObjCMethodSpecifier,
___
cfe-commits mailing list
cfe-commits@lists.

[PATCH] D147577: [Format/ObjC] Support NS_ERROR_ENUM in ObjC language guesser

2023-04-04 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay accepted this revision.
MyDeveloperDay added a comment.
This revision is now accepted and ready to land.

LGTM


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D147577/new/

https://reviews.llvm.org/D147577

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D147577: [Format/ObjC] Support NS_ERROR_ENUM in ObjC language guesser

2023-04-04 Thread Ben Hamilton via Phabricator via cfe-commits
benhamilton created this revision.
benhamilton added reviewers: sammccall, MyDeveloperDay.
Herald added projects: All, clang, clang-format.
Herald added a subscriber: cfe-commits.
Herald added reviewers: rymiel, HazardyKnusperkeks, owenpan.
benhamilton requested review of this revision.

Apple added a new NS_ERROR_ENUM macro to help define enums for
NSError codes.

This updates libformat's Objective-C language-guessing heuristic
to detect the new macro as well as related NSError types.

Tested: New tests added.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D147577

Files:
  clang/lib/Format/Format.cpp
  clang/lib/Format/FormatToken.h
  clang/unittests/Format/FormatTestObjC.cpp


Index: clang/unittests/Format/FormatTestObjC.cpp
===
--- clang/unittests/Format/FormatTestObjC.cpp
+++ clang/unittests/Format/FormatTestObjC.cpp
@@ -89,6 +89,11 @@
   ASSERT_TRUE((bool)Style);
   EXPECT_EQ(FormatStyle::LK_ObjC, Style->Language);
 
+  Style =
+  getStyle("{}", "a.h", "none", "typedef NS_ERROR_ENUM(int, Foo) {};\n");
+  ASSERT_TRUE((bool)Style);
+  EXPECT_EQ(FormatStyle::LK_ObjC, Style->Language);
+
   Style = getStyle("{}", "a.h", "none", "enum Foo {};");
   ASSERT_TRUE((bool)Style);
   EXPECT_EQ(FormatStyle::LK_Cpp, Style->Language);
Index: clang/lib/Format/FormatToken.h
===
--- clang/lib/Format/FormatToken.h
+++ clang/lib/Format/FormatToken.h
@@ -949,6 +949,7 @@
 kw_CF_OPTIONS = &IdentTable.get("CF_OPTIONS");
 kw_NS_CLOSED_ENUM = &IdentTable.get("NS_CLOSED_ENUM");
 kw_NS_ENUM = &IdentTable.get("NS_ENUM");
+kw_NS_ERROR_ENUM = &IdentTable.get("NS_ERROR_ENUM");
 kw_NS_OPTIONS = &IdentTable.get("NS_OPTIONS");
 
 kw_as = &IdentTable.get("as");
@@ -1334,6 +1335,7 @@
   IdentifierInfo *kw_CF_OPTIONS;
   IdentifierInfo *kw_NS_CLOSED_ENUM;
   IdentifierInfo *kw_NS_ENUM;
+  IdentifierInfo *kw_NS_ERROR_ENUM;
   IdentifierInfo *kw_NS_OPTIONS;
   IdentifierInfo *kw___except;
   IdentifierInfo *kw___has_include;
Index: clang/lib/Format/Format.cpp
===
--- clang/lib/Format/Format.cpp
+++ clang/lib/Format/Format.cpp
@@ -2699,6 +2699,8 @@
 "NSDecimalNumber",
 "NSDictionary",
 "NSEdgeInsets",
+"NSError",
+"NSErrorDomain",
 "NSHashTable",
 "NSIndexPath",
 "NSIndexSet",
@@ -2760,6 +2762,7 @@
 FormatTok->TokenText)) ||
 FormatTok->is(TT_ObjCStringLiteral) ||
 FormatTok->isOneOf(Keywords.kw_NS_CLOSED_ENUM, Keywords.kw_NS_ENUM,
+   Keywords.kw_NS_ERROR_ENUM,
Keywords.kw_NS_OPTIONS, TT_ObjCBlockLBrace,
TT_ObjCBlockLParen, TT_ObjCDecl, TT_ObjCForIn,
TT_ObjCMethodExpr, TT_ObjCMethodSpecifier,


Index: clang/unittests/Format/FormatTestObjC.cpp
===
--- clang/unittests/Format/FormatTestObjC.cpp
+++ clang/unittests/Format/FormatTestObjC.cpp
@@ -89,6 +89,11 @@
   ASSERT_TRUE((bool)Style);
   EXPECT_EQ(FormatStyle::LK_ObjC, Style->Language);
 
+  Style =
+  getStyle("{}", "a.h", "none", "typedef NS_ERROR_ENUM(int, Foo) {};\n");
+  ASSERT_TRUE((bool)Style);
+  EXPECT_EQ(FormatStyle::LK_ObjC, Style->Language);
+
   Style = getStyle("{}", "a.h", "none", "enum Foo {};");
   ASSERT_TRUE((bool)Style);
   EXPECT_EQ(FormatStyle::LK_Cpp, Style->Language);
Index: clang/lib/Format/FormatToken.h
===
--- clang/lib/Format/FormatToken.h
+++ clang/lib/Format/FormatToken.h
@@ -949,6 +949,7 @@
 kw_CF_OPTIONS = &IdentTable.get("CF_OPTIONS");
 kw_NS_CLOSED_ENUM = &IdentTable.get("NS_CLOSED_ENUM");
 kw_NS_ENUM = &IdentTable.get("NS_ENUM");
+kw_NS_ERROR_ENUM = &IdentTable.get("NS_ERROR_ENUM");
 kw_NS_OPTIONS = &IdentTable.get("NS_OPTIONS");
 
 kw_as = &IdentTable.get("as");
@@ -1334,6 +1335,7 @@
   IdentifierInfo *kw_CF_OPTIONS;
   IdentifierInfo *kw_NS_CLOSED_ENUM;
   IdentifierInfo *kw_NS_ENUM;
+  IdentifierInfo *kw_NS_ERROR_ENUM;
   IdentifierInfo *kw_NS_OPTIONS;
   IdentifierInfo *kw___except;
   IdentifierInfo *kw___has_include;
Index: clang/lib/Format/Format.cpp
===
--- clang/lib/Format/Format.cpp
+++ clang/lib/Format/Format.cpp
@@ -2699,6 +2699,8 @@
 "NSDecimalNumber",
 "NSDictionary",
 "NSEdgeInsets",
+"NSError",
+"NSErrorDomain",
 "NSHashTable",
 "NSIndexPath",
 "NSIndexSet",
@@ -2760,6 +2762,7 @@
 FormatTok->TokenText)) ||
 FormatTok->is(TT_ObjCStringLiteral) ||
 FormatTok->isOneOf(Keywords.kw_NS_CLOSED_ENUM, Keywords.kw_NS_ENUM,
+