1

I’ve started using clang-tidy on my cmake based project that runs on macOS platform.

Unfortunately, this option isn’t supported on Xcode project generation but only in Makefile.

So when I compiled on the first time, one of the error related to a system include line #import <Foundation/Foundation.h> it fails:

/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX12.1.sdk/System/Library/Frameworks/Foundation.framework/Headers/NSBundle.h:91:143: error: function does not return NSString [clang-diagnostic-error]
- (NSAttributedString *)localizedAttributedStringForKey:(NSString *)key value:(nullable NSString *)value table:(nullable NSString *)tableName NS_FORMAT_ARGUMENT(1) NS_REFINED_FOR_SWIFT API_AVAILABLE(macos(12.0), ios(15.0), watchos(8.0), tvos(15.0));
                                                                                                                                              ^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX12.1.sdk/System/Library/Frameworks/Foundation.framework/Headers/NSObjCRuntime.h:103:48: note: expanded from macro 'NS_FORMAT_ARGUMENT'
        #define NS_FORMAT_ARGUMENT(A) __attribute__ ((format_arg(A)))
                                                      ^

Although it seems correct I’d like to ignore it, but couldn’t do so with // NOLINT since it’s header file, So i’ve read about NOLINTBEGIN and NOLINTEND but it’s supported from llvm 14 and Apple has llvm 12.0.1 and I don’t want to update the entire package because it’s used by Xcode

clang-tidy --version Homebrew LLVM version 12.0.1 Optimized build. Default target: x86_64-apple-darwin20.6.0 Host CPU: skylake

any idea how to resolve this clang-tidy issue with macOS and avoid system includes ?

Zohar81
  • 4,554
  • 5
  • 29
  • 82
  • The .mm extensions indicate that file you process is in language named Objective C. Remove C++ tag from your question and add objective-c – Öö Tiib Jan 15 '22 at 08:30

1 Answers1

0

We also encountered this problem. When we updated clang-tidy to clang-13(we installed it by macports) the problem disappeared.

kkpattern
  • 948
  • 2
  • 7
  • 31