diff options
author | David Goldman <dallasftball@gmail.com> | 2019-04-04 20:13:22 +0000 |
---|---|---|
committer | David Goldman <dallasftball@gmail.com> | 2019-04-04 20:13:22 +0000 |
commit | 19d21854e92ed3acdeee17a6c2dd106f9e9dd058 (patch) | |
tree | 777c450c969afdf33dbe0c8bd839cd36c637df48 /clang/unittests/AST | |
parent | e028de43cd5fcad19736cd9b3352ef8530419ba9 (diff) | |
download | bcm5719-llvm-19d21854e92ed3acdeee17a6c2dd106f9e9dd058.tar.gz bcm5719-llvm-19d21854e92ed3acdeee17a6c2dd106f9e9dd058.zip |
Special case ObjCPropertyDecl for printing
ObjCPropertyDecl should use the category interface as a context similar to what is done for methods.
Previously category methods would be printed as `::property`; now they are printed as `Class::property`.
llvm-svn: 357720
Diffstat (limited to 'clang/unittests/AST')
-rw-r--r-- | clang/unittests/AST/NamedDeclPrinterTest.cpp | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/clang/unittests/AST/NamedDeclPrinterTest.cpp b/clang/unittests/AST/NamedDeclPrinterTest.cpp index 172268cc9f4..d97299bc191 100644 --- a/clang/unittests/AST/NamedDeclPrinterTest.cpp +++ b/clang/unittests/AST/NamedDeclPrinterTest.cpp @@ -115,6 +115,18 @@ PrintedWrittenNamedDeclCXX11Matches(StringRef Code, StringRef DeclName, "input.cc"); } +::testing::AssertionResult +PrintedWrittenPropertyDeclObjCMatches(StringRef Code, StringRef DeclName, + StringRef ExpectedPrinted) { + std::vector<std::string> Args{"-std=c++11", "-xobjective-c++"}; + return PrintedNamedDeclMatches(Code, + Args, + /*SuppressUnwrittenScope*/ true, + objcPropertyDecl(hasName(DeclName)).bind("id"), + ExpectedPrinted, + "input.m"); +} + } // unnamed namespace TEST(NamedDeclPrinter, TestNamespace1) { @@ -179,3 +191,31 @@ TEST(NamedDeclPrinter, TestLinkageInNamespace) { "A", "X::A")); } + +TEST(NamedDeclPrinter, TestObjCClassExtension) { + ASSERT_TRUE(PrintedWrittenPropertyDeclObjCMatches( + R"( + @interface Obj + @end + + @interface Obj () + @property(nonatomic) int property; + @end + )", + "property", + "Obj::property")); +} + +TEST(NamedDeclPrinter, TestObjCClassExtensionWithGetter) { + ASSERT_TRUE(PrintedWrittenPropertyDeclObjCMatches( + R"( + @interface Obj + @end + + @interface Obj () + @property(nonatomic, getter=myPropertyGetter) int property; + @end + )", + "property", + "Obj::property")); +} |