[PATCH] D45912: update test to use ivar in implementation instead of class extension

Yan Zhang via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Sun Apr 22 17:18:37 PDT 2018


This revision was automatically updated to reflect the committed changes.
Closed by commit rL330559: update test to use ivar in implementation instead of class extension (authored by Wizard, committed by ).
Herald added a subscriber: llvm-commits.

Repository:
  rL LLVM

https://reviews.llvm.org/D45912

Files:
  clang-tools-extra/trunk/clang-tidy/readability/IdentifierNamingCheck.cpp
  clang-tools-extra/trunk/test/clang-tidy/readability-identifier-naming-objc.m


Index: clang-tools-extra/trunk/clang-tidy/readability/IdentifierNamingCheck.cpp
===================================================================
--- clang-tools-extra/trunk/clang-tidy/readability/IdentifierNamingCheck.cpp
+++ clang-tools-extra/trunk/clang-tidy/readability/IdentifierNamingCheck.cpp
@@ -109,6 +109,7 @@
     m(TemplateParameter) \
     m(TypeAlias) \
     m(MacroDefinition) \
+    m(ObjcIvar) \
 
 enum StyleKind {
 #define ENUMERATE(v) SK_ ## v,
@@ -384,6 +385,9 @@
     const NamedDecl *D,
     const std::vector<llvm::Optional<IdentifierNamingCheck::NamingStyle>>
         &NamingStyles) {
+  if (isa<ObjCIvarDecl>(D) && NamingStyles[SK_ObjcIvar])
+    return SK_ObjcIvar;
+  
   if (isa<TypedefDecl>(D) && NamingStyles[SK_Typedef])
     return SK_Typedef;
 
Index: clang-tools-extra/trunk/test/clang-tidy/readability-identifier-naming-objc.m
===================================================================
--- clang-tools-extra/trunk/test/clang-tidy/readability-identifier-naming-objc.m
+++ clang-tools-extra/trunk/test/clang-tidy/readability-identifier-naming-objc.m
@@ -0,0 +1,15 @@
+// RUN: %check_clang_tidy %s readability-identifier-naming %t \
+// RUN: -config='{CheckOptions: \
+// RUN:  [{key: readability-identifier-naming.ObjcIvarPrefix, value: '_'}]}' \
+// RUN: --
+
+ at interface Foo
+ at end 
+
+ at implementation Foo {
+    int _bar;
+    int barWithoutPrefix;
+    // CHECK-MESSAGES: :[[@LINE-1]]:9: warning: invalid case style for objc ivar 'barWithoutPrefix' [readability-identifier-naming]
+    // CHECK-FIXES: int _barWithoutPrefix;
+}
+ at end


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D45912.143495.patch
Type: text/x-patch
Size: 1583 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20180423/f423ce84/attachment-0001.bin>


More information about the cfe-commits mailing list