From ea865c6a243483227aa2abee76f82fda45c25757 Mon Sep 17 00:00:00 2001 From: Lukhnos Liu Date: Sat, 1 Dec 2018 06:58:42 -0800 Subject: [PATCH] Fix a static analyzer warning --- Source/InputMethodController.mm | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/Source/InputMethodController.mm b/Source/InputMethodController.mm index 74c58ecb..3ef36cc7 100644 --- a/Source/InputMethodController.mm +++ b/Source/InputMethodController.mm @@ -114,6 +114,12 @@ static NSString *const kGraphVizOutputfile = @"/tmp/McBopomofo-visualization.dot FastLM gLanguageModel; FastLM gLanguageModelPlainBopomofo; +// https://clang-analyzer.llvm.org/faq.html +__attribute__((annotate("returns_localized_nsstring"))) +static inline NSString *LocalizationNotNeeded(NSString *s) { + return s; +} + // private methods @interface McBopomofoInputMethodController () + (VTHorizontalCandidateController *)horizontalCandidateController; @@ -200,7 +206,7 @@ public: - (NSMenu *)menu { // a menu instance (autoreleased) is requested every time the user click on the input menu - NSMenu *menu = [[[NSMenu alloc] initWithTitle:@"Input Method Menu"] autorelease]; + NSMenu *menu = [[[NSMenu alloc] initWithTitle:LocalizationNotNeeded(@"Input Method Menu")] autorelease]; NSMenuItem *preferenceMenuItem = [[[NSMenuItem alloc] initWithTitle:NSLocalizedString(@"McBopomofo Preferences", @"") action:@selector(showPreferences:) keyEquivalent:@""] autorelease]; [menu addItem:preferenceMenuItem];