[PATCH] D62045: Modified global variable declaration to fit updated objc guide.

Stephane Moore via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri May 17 15:03:15 PDT 2019


stephanemoore requested changes to this revision.
stephanemoore added a comment.
This revision now requires changes to proceed.

Thanks for restoring the support for the legacy style! I noticed that there are some cases where we can preserve an existing fixit.



================
Comment at: clang-tools-extra/clang-tidy/google/GlobalVariableDeclarationCheck.cpp:45
+
+  if (IsConst) {
+    // No fix available if it is a global constant, since it is difficult to
----------------
We can still emit a fix for static constants. Perhaps only early return if the variable declaration is both constant and static?


================
Comment at: clang-tools-extra/test/clang-tidy/google-objc-global-variable-declaration.m:6
-// CHECK-MESSAGES: :[[@LINE-1]]:24: warning: const global variable 'myConstString' must have a name which starts with an appropriate prefix [google-objc-global-variable-declaration]
-// CHECK-FIXES: static NSString* const kMyConstString = @"hello";
 
----------------
This is still a valid fix that we can emit.

Maybe we can just recommend a fix for static constants?

Maybe we can add a case that we don't believe should have an emitted fixit like so:
```
extern NSString *const GlobalConstant;
```


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D62045





More information about the cfe-commits mailing list