https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109462
Bug ID: 109462 Summary: [13 Regression] Possible miscompilation of clang LocalizationChecker since r13-1938 Product: gcc Version: 13.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: tree-optimization Assignee: unassigned at gcc dot gnu.org Reporter: jakub at gcc dot gnu.org Target Milestone: --- Created attachment 54823 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=54823&action=edit LocalizationChecker.ii.xz As mentioned in (but not reported to us) in https://github.com/llvm/llvm-project/issues/59227 // clang -cc1 test.m -analyze -setup-static-analyzer -analyzer-checker=optin.osx.cocoa.localizability.EmptyLocalizationContextChecker #define nil ((id)0) #define NSLocalizedString(key, comment) [[NSBundle mainBundle] localizedStringForKey:(key) value:@"" table:nil] struct CGPoint { double x; double y; }; typedef struct CGPoint CGPoint; @interface NSObject + (id)alloc; - (id)init; @end @class NSDictionary; @interface NSString : NSObject - (void)drawAtPoint:(CGPoint)point withAttributes:(NSDictionary *)attrs; + (instancetype)localizedStringWithFormat:(NSString *)format, ...; @end @interface NSBundle : NSObject + (NSBundle *)mainBundle; - (NSString *)localizedStringForKey:(NSString *)key value:(NSString *)value table:(NSString *)tableName; @end @interface LocalizationTestSuite : NSObject @end @implementation LocalizationTestSuite - (void)testNilLocalizationContext { NSString *string = NSLocalizedString(@"LocalizedString", nil); } @end reports an (expected) warning when clang/lib/StaticAnalyzer/Checkers/LocalizationChecker.cpp is compiled with r13-1937 and earlier, while when compiled with r13-1938 and later the warning is not emitted. The r13-1938 changes cause differences in _ZNK5clang13SourceManager16getDecomposedLocENS_14SourceLocationE and _ZN12_GLOBAL__N_131EmptyLocalizationContextChecker13MethodCrawler20VisitObjCMessageExprEPKN5clang15ObjCMessageExprE functions and it is the latter that matters for whether the warning is reported or not (proved by hand-combining assembly from the 2 revisions, everything from r13-1937 but the _ZN12_GLOBAL__N_131EmptyLocalizationContextChecker13MethodCrawler20VisitObjCMessageExprEPKN5clang15ObjCMessageExprE function from r13-1938 doesn't report the warning, everything from r13-1938 but that function from r13-1937 does. First difference in both functions appears in the dom2 dumps. Flags used to compile were -fPIC -fno-semantic-interposition -fvisibility-inlines-hidden -ffunction-sections -fdata-sections -fno-common -fno-strict-aliasing -O3 -fno-exceptions -funwind-tables -fno-rtti -std=c++17 LocalizationChecker.ii