[PATCH] D151578: [Format/ObjC] Support NS_ASSUME_NONNULL_BEGIN and FOUNDATION_EXPORT in ObjC language guesser
Ben Hamilton via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Fri May 26 12:03:21 PDT 2023
benhamilton updated this revision to Diff 526151.
benhamilton added a comment.
Fix auto-complete-o.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D151578/new/
https://reviews.llvm.org/D151578
Files:
clang/lib/Format/Format.cpp
clang/test/Format/dump-config-objc-macros.h
clang/unittests/Format/FormatTestObjC.cpp
Index: clang/unittests/Format/FormatTestObjC.cpp
===================================================================
--- clang/unittests/Format/FormatTestObjC.cpp
+++ clang/unittests/Format/FormatTestObjC.cpp
@@ -94,6 +94,20 @@
ASSERT_TRUE((bool)Style);
EXPECT_EQ(FormatStyle::LK_ObjC, Style->Language);
+ Style = getStyle("{}", "a.h", "none", R"objc(
+NS_ASSUME_NONNULL_BEGIN
+extern int i;
+NS_ASSUME_NONNULL_END
+)objc");
+ ASSERT_TRUE((bool)Style);
+ EXPECT_EQ(FormatStyle::LK_ObjC, Style->Language);
+
+ Style = getStyle("{}", "a.h", "none", R"objc(
+FOUNDATION_EXTERN void DoStuff(void);
+)objc");
+ 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/test/Format/dump-config-objc-macros.h
===================================================================
--- /dev/null
+++ clang/test/Format/dump-config-objc-macros.h
@@ -0,0 +1,8 @@
+// RUN: clang-format -dump-config %s | FileCheck %s
+
+// CHECK: Language: ObjC
+NS_ASSUME_NONNULL_BEGIN
+
+FOUNDATION_EXTERN int kConstant;
+
+NS_ASSUME_NONNULL_END
Index: clang/lib/Format/Format.cpp
===================================================================
--- clang/lib/Format/Format.cpp
+++ clang/lib/Format/Format.cpp
@@ -2687,6 +2687,7 @@
"CGSizeMake",
"CGVector",
"CGVectorMake",
+ "FOUNDATION_EXTERN",
"NSAffineTransform",
"NSArray",
"NSAttributedString",
@@ -2743,6 +2744,7 @@
"NSURLQueryItem",
"NSUUID",
"NSValue",
+ "NS_ASSUME_NONNULL_BEGIN",
"UIImage",
"UIView",
};
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D151578.526151.patch
Type: text/x-patch
Size: 1743 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20230526/24d99437/attachment.bin>
More information about the cfe-commits
mailing list