Jake-Egan created this revision. Jake-Egan requested review of this revision. Herald added a project: clang. Herald added a subscriber: cfe-commits.
Repository: rG LLVM Github Monorepo https://reviews.llvm.org/D117315 Files: clang/lib/Sema/SemaChecking.cpp clang/test/Analysis/cfref_PR2519.c clang/test/CodeGen/cfstring2.c clang/test/Modules/builtins.m clang/test/SemaCXX/builtins.cpp
Index: clang/test/SemaCXX/builtins.cpp =================================================================== --- clang/test/SemaCXX/builtins.cpp +++ clang/test/SemaCXX/builtins.cpp @@ -4,7 +4,11 @@ #define CFSTR __builtin___CFStringMakeConstantString void f() { +#if !defined(__MVS__) && !defined(_AIX) + // Builtin function __builtin___CFStringMakeConstantString is currently + // unsupported on z/OS and AIX. (void)CFStringRef(CFSTR("Hello")); +#endif } void a() { __builtin_va_list x, y; ::__builtin_va_copy(x, y); } Index: clang/test/Modules/builtins.m =================================================================== --- clang/test/Modules/builtins.m +++ clang/test/Modules/builtins.m @@ -1,3 +1,4 @@ +// UNSUPPORTED: -zos, -aix // RUN: rm -rf %t // RUN: %clang_cc1 -fmodules-cache-path=%t -fmodules -fimplicit-module-maps -I %S/Inputs %s -verify // RUN: %clang_cc1 -fmodules-cache-path=%t -fmodules -fimplicit-module-maps -I %S/Inputs -x c %s -verify Index: clang/test/CodeGen/cfstring2.c =================================================================== --- clang/test/CodeGen/cfstring2.c +++ clang/test/CodeGen/cfstring2.c @@ -1,3 +1,4 @@ +// UNSUPPORTED: -zos, -aix // RUN: %clang_cc1 -emit-llvm %s -o %t typedef const struct __CFString * CFStringRef; Index: clang/test/Analysis/cfref_PR2519.c =================================================================== --- clang/test/Analysis/cfref_PR2519.c +++ clang/test/Analysis/cfref_PR2519.c @@ -1,3 +1,4 @@ +// UNSUPPORTED: -zos, -aix // RUN: %clang_analyze_cc1 -analyzer-checker=core,osx.cocoa.RetainCount,alpha.core -analyzer-store=region -verify %s // expected-no-diagnostics Index: clang/lib/Sema/SemaChecking.cpp =================================================================== --- clang/lib/Sema/SemaChecking.cpp +++ clang/lib/Sema/SemaChecking.cpp @@ -1578,11 +1578,26 @@ return TheCall; } +// Emit an error and return true if the current object format type is in the +// list of unsupported types. +static bool CheckBuiltinTargetNotInUnsupported( + Sema &S, unsigned BuiltinID, CallExpr *TheCall, + ArrayRef<llvm::Triple::ObjectFormatType> UnsupportedObjectFormatTypes) { + llvm::Triple::ObjectFormatType CurObjFormat = + S.getASTContext().getTargetInfo().getTriple().getObjectFormat(); + if (llvm::is_contained(UnsupportedObjectFormatTypes, CurObjFormat)) { + S.Diag(TheCall->getBeginLoc(), diag::err_builtin_target_unsupported) + << TheCall->getSourceRange(); + return true; + } + return false; +} + // Emit an error and return true if the current architecture is not in the list // of supported architectures. static bool -CheckBuiltinTargetSupport(Sema &S, unsigned BuiltinID, CallExpr *TheCall, - ArrayRef<llvm::Triple::ArchType> SupportedArchs) { +CheckBuiltinTargetInSupported(Sema &S, unsigned BuiltinID, CallExpr *TheCall, + ArrayRef<llvm::Triple::ArchType> SupportedArchs) { llvm::Triple::ArchType CurArch = S.getASTContext().getTargetInfo().getTriple().getArch(); if (llvm::is_contained(SupportedArchs, CurArch)) @@ -1664,6 +1679,12 @@ switch (BuiltinID) { case Builtin::BI__builtin___CFStringMakeConstantString: + // CFStringMakeConstantString is currently not implemented for GOFF (i.e., + // on z/OS) and for XCOFF (i.e., on AIX). Emit unsupported + if (CheckBuiltinTargetNotInUnsupported( + *this, BuiltinID, TheCall, + {llvm::Triple::GOFF, llvm::Triple::XCOFF})) + return ExprError(); assert(TheCall->getNumArgs() == 1 && "Wrong # arguments to builtin CFStringMakeConstantString"); if (CheckObjCString(TheCall->getArg(0))) @@ -1698,7 +1719,7 @@ case Builtin::BI_interlockedbittestandreset_acq: case Builtin::BI_interlockedbittestandreset_rel: case Builtin::BI_interlockedbittestandreset_nf: - if (CheckBuiltinTargetSupport( + if (CheckBuiltinTargetInSupported( *this, BuiltinID, TheCall, {llvm::Triple::arm, llvm::Triple::thumb, llvm::Triple::aarch64})) return ExprError(); @@ -1711,9 +1732,10 @@ case Builtin::BI_bittestandset64: case Builtin::BI_interlockedbittestandreset64: case Builtin::BI_interlockedbittestandset64: - if (CheckBuiltinTargetSupport(*this, BuiltinID, TheCall, - {llvm::Triple::x86_64, llvm::Triple::arm, - llvm::Triple::thumb, llvm::Triple::aarch64})) + if (CheckBuiltinTargetInSupported(*this, BuiltinID, TheCall, + {llvm::Triple::x86_64, llvm::Triple::arm, + llvm::Triple::thumb, + llvm::Triple::aarch64})) return ExprError(); break;
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits