From a83a6c22e63ad84e9c210c71b36413bed72ac23c Mon Sep 17 00:00:00 2001 From: Zarko Todorovski Date: Fri, 5 Nov 2021 11:27:59 -0400 Subject: [PATCH] [clang] [Objective C] Inclusive language: use objcmt-allowlist-dir-path= instead of objcmt-white-list-dir-path= Trying to update some options that don't at least have an inclusive language version. This patch adds `objcmt-allowlist-dir-path` as a default alternative. Reviewed By: akyrtzi Differential Revision: https://reviews.llvm.org/D112591 --- clang/docs/ClangCommandLineReference.rst | 2 +- clang/include/clang/Driver/Options.td | 9 ++++--- .../include/clang/Frontend/FrontendOptions.h | 2 +- clang/lib/ARCMigrate/ObjCMT.cpp | 26 +++++++++---------- clang/lib/Driver/ToolChains/Clang.cpp | 2 +- .../Inputs/header1.h | 0 .../{whitelisted => allowlisted}/header1.h | 0 .../header1.h.result | 0 .../{whitelisted => allowlisted}/header2.h | 0 .../header2.h.result | 0 .../objcmt-with-allowlist-impl.m} | 2 +- .../objcmt-with-allowlist-impl.m.result} | 2 +- .../objcmt-with-allowlist.m} | 2 +- clang/test/SemaObjC/method-conflict-1.m | 2 +- clang/test/SemaObjC/method-conflict-2.m | 2 +- clang/test/SemaObjC/method-typecheck-3.m | 2 +- 16 files changed, 28 insertions(+), 25 deletions(-) rename clang/test/ARCMT/{whitelisted => allowlisted}/Inputs/header1.h (100%) rename clang/test/ARCMT/{whitelisted => allowlisted}/header1.h (100%) rename clang/test/ARCMT/{whitelisted => allowlisted}/header1.h.result (100%) rename clang/test/ARCMT/{whitelisted => allowlisted}/header2.h (100%) rename clang/test/ARCMT/{whitelisted => allowlisted}/header2.h.result (100%) rename clang/test/ARCMT/{whitelisted/objcmt-with-whitelist-impl.m => allowlisted/objcmt-with-allowlist-impl.m} (75%) rename clang/test/ARCMT/{whitelisted/objcmt-with-whitelist-impl.m.result => allowlisted/objcmt-with-allowlist-impl.m.result} (75%) rename clang/test/ARCMT/{whitelisted/objcmt-with-whitelist.m => allowlisted/objcmt-with-allowlist.m} (79%) diff --git a/clang/docs/ClangCommandLineReference.rst b/clang/docs/ClangCommandLineReference.rst index 31e7cd342c26..94eb3fec8a23 100644 --- a/clang/docs/ClangCommandLineReference.rst +++ b/clang/docs/ClangCommandLineReference.rst @@ -483,7 +483,7 @@ Enable migration to use NS\_NONATOMIC\_IOSONLY macro for setting property's 'ato Enable migration to annotate property with NS\_RETURNS\_INNER\_POINTER -.. option:: -objcmt-whitelist-dir-path=, -objcmt-white-list-dir-path= +.. option:: -objcmpt-allowlist-dir-path=, -objcmt-whitelist-dir-path=, -objcmt-white-list-dir-path= Only modify files with a filename contained in the provided directory path diff --git a/clang/include/clang/Driver/Options.td b/clang/include/clang/Driver/Options.td index b4a2411fa5c5..9a657e948e33 100644 --- a/clang/include/clang/Driver/Options.td +++ b/clang/include/clang/Driver/Options.td @@ -617,12 +617,15 @@ def objcmt_migrate_designated_init : Flag<["-"], "objcmt-migrate-designated-init HelpText<"Enable migration to infer NS_DESIGNATED_INITIALIZER for initializer methods">, MarshallingInfoBitfieldFlag, "FrontendOptions::ObjCMT_DesignatedInitializer">; -def objcmt_whitelist_dir_path: Joined<["-"], "objcmt-whitelist-dir-path=">, Flags<[CC1Option]>, +def objcmt_allowlist_dir_path: Joined<["-"], "objcmt-allowlist-dir-path=">, Flags<[CC1Option]>, HelpText<"Only modify files with a filename contained in the provided directory path">, - MarshallingInfoString>; + MarshallingInfoString>; +def : Joined<["-"], "objcmt-whitelist-dir-path=">, Flags<[CC1Option]>, + HelpText<"Alias for -objcmt-allowlist-dir-path">, + Alias; // The misspelt "white-list" [sic] alias is due for removal. def : Joined<["-"], "objcmt-white-list-dir-path=">, Flags<[CC1Option]>, - Alias; + Alias; // Make sure all other -ccc- options are rejected. def ccc_ : Joined<["-"], "ccc-">, Group, Flags<[Unsupported]>; diff --git a/clang/include/clang/Frontend/FrontendOptions.h b/clang/include/clang/Frontend/FrontendOptions.h index 41ea45ca0b10..1d9d89a28c6c 100644 --- a/clang/include/clang/Frontend/FrontendOptions.h +++ b/clang/include/clang/Frontend/FrontendOptions.h @@ -373,7 +373,7 @@ public: ObjCMT_MigrateDecls | ObjCMT_PropertyDotSyntax) }; unsigned ObjCMTAction = ObjCMT_None; - std::string ObjCMTWhiteListPath; + std::string ObjCMTAllowListPath; std::string MTMigrateDir; std::string ARCMTMigrateReportOut; diff --git a/clang/lib/ARCMigrate/ObjCMT.cpp b/clang/lib/ARCMigrate/ObjCMT.cpp index e99c6435062f..3dfa9a0218a7 100644 --- a/clang/lib/ARCMigrate/ObjCMT.cpp +++ b/clang/lib/ARCMigrate/ObjCMT.cpp @@ -104,7 +104,7 @@ public: bool FoundationIncluded; llvm::SmallPtrSet ObjCProtocolDecls; llvm::SmallVector CFFunctionIBCandidates; - llvm::StringSet<> WhiteListFilenames; + llvm::StringSet<> AllowListFilenames; RetainSummaryManager &getSummaryManager(ASTContext &Ctx) { if (!Summaries) @@ -118,14 +118,14 @@ public: FileRemapper &remapper, FileManager &fileMgr, const PPConditionalDirectiveRecord *PPRec, Preprocessor &PP, bool isOutputFile, - ArrayRef WhiteList) + ArrayRef AllowList) : MigrateDir(migrateDir), ASTMigrateActions(astMigrateActions), NSIntegerTypedefed(nullptr), NSUIntegerTypedefed(nullptr), Remapper(remapper), FileMgr(fileMgr), PPRec(PPRec), PP(PP), IsOutputFile(isOutputFile), FoundationIncluded(false) { // FIXME: StringSet should have insert(iter, iter) to use here. - for (const std::string &Val : WhiteList) - WhiteListFilenames.insert(Val); + for (const std::string &Val : AllowList) + AllowListFilenames.insert(Val); } protected: @@ -151,10 +151,10 @@ protected: void HandleTranslationUnit(ASTContext &Ctx) override; bool canModifyFile(StringRef Path) { - if (WhiteListFilenames.empty()) + if (AllowListFilenames.empty()) return true; - return WhiteListFilenames.find(llvm::sys::path::filename(Path)) - != WhiteListFilenames.end(); + return AllowListFilenames.find(llvm::sys::path::filename(Path)) != + AllowListFilenames.end(); } bool canModifyFile(Optional FE) { if (!FE) @@ -1986,7 +1986,7 @@ bool MigrateSourceAction::BeginInvocation(CompilerInstance &CI) { return true; } -static std::vector getWhiteListFilenames(StringRef DirPath) { +static std::vector getAllowListFilenames(StringRef DirPath) { using namespace llvm::sys::fs; using namespace llvm::sys::path; @@ -2017,16 +2017,16 @@ MigrateSourceAction::CreateASTConsumer(CompilerInstance &CI, StringRef InFile) { if (ObjCMTOpts == FrontendOptions::ObjCMT_None) { // If no specific option was given, enable literals+subscripting transforms // by default. - ObjCMTAction |= FrontendOptions::ObjCMT_Literals | - FrontendOptions::ObjCMT_Subscripting; + ObjCMTAction |= + FrontendOptions::ObjCMT_Literals | FrontendOptions::ObjCMT_Subscripting; } CI.getPreprocessor().addPPCallbacks(std::unique_ptr(PPRec)); - std::vector WhiteList = - getWhiteListFilenames(CI.getFrontendOpts().ObjCMTWhiteListPath); + std::vector AllowList = + getAllowListFilenames(CI.getFrontendOpts().ObjCMTAllowListPath); return std::make_unique( CI.getFrontendOpts().OutputFile, ObjCMTAction, Remapper, CI.getFileManager(), PPRec, CI.getPreprocessor(), - /*isOutputFile=*/true, WhiteList); + /*isOutputFile=*/true, AllowList); } namespace { diff --git a/clang/lib/Driver/ToolChains/Clang.cpp b/clang/lib/Driver/ToolChains/Clang.cpp index 2dd10a7b3106..56fe3ca59988 100644 --- a/clang/lib/Driver/ToolChains/Clang.cpp +++ b/clang/lib/Driver/ToolChains/Clang.cpp @@ -3388,7 +3388,7 @@ static void RenderARCMigrateToolOptions(const Driver &D, const ArgList &Args, Args.AddLastArg(CmdArgs, options::OPT_objcmt_returns_innerpointer_property); Args.AddLastArg(CmdArgs, options::OPT_objcmt_ns_nonatomic_iosonly); Args.AddLastArg(CmdArgs, options::OPT_objcmt_migrate_designated_init); - Args.AddLastArg(CmdArgs, options::OPT_objcmt_whitelist_dir_path); + Args.AddLastArg(CmdArgs, options::OPT_objcmt_allowlist_dir_path); } } diff --git a/clang/test/ARCMT/whitelisted/Inputs/header1.h b/clang/test/ARCMT/allowlisted/Inputs/header1.h similarity index 100% rename from clang/test/ARCMT/whitelisted/Inputs/header1.h rename to clang/test/ARCMT/allowlisted/Inputs/header1.h diff --git a/clang/test/ARCMT/whitelisted/header1.h b/clang/test/ARCMT/allowlisted/header1.h similarity index 100% rename from clang/test/ARCMT/whitelisted/header1.h rename to clang/test/ARCMT/allowlisted/header1.h diff --git a/clang/test/ARCMT/whitelisted/header1.h.result b/clang/test/ARCMT/allowlisted/header1.h.result similarity index 100% rename from clang/test/ARCMT/whitelisted/header1.h.result rename to clang/test/ARCMT/allowlisted/header1.h.result diff --git a/clang/test/ARCMT/whitelisted/header2.h b/clang/test/ARCMT/allowlisted/header2.h similarity index 100% rename from clang/test/ARCMT/whitelisted/header2.h rename to clang/test/ARCMT/allowlisted/header2.h diff --git a/clang/test/ARCMT/whitelisted/header2.h.result b/clang/test/ARCMT/allowlisted/header2.h.result similarity index 100% rename from clang/test/ARCMT/whitelisted/header2.h.result rename to clang/test/ARCMT/allowlisted/header2.h.result diff --git a/clang/test/ARCMT/whitelisted/objcmt-with-whitelist-impl.m b/clang/test/ARCMT/allowlisted/objcmt-with-allowlist-impl.m similarity index 75% rename from clang/test/ARCMT/whitelisted/objcmt-with-whitelist-impl.m rename to clang/test/ARCMT/allowlisted/objcmt-with-allowlist-impl.m index d734eaa10bdf..36797eb1c843 100644 --- a/clang/test/ARCMT/whitelisted/objcmt-with-whitelist-impl.m +++ b/clang/test/ARCMT/allowlisted/objcmt-with-allowlist-impl.m @@ -1,5 +1,5 @@ // RUN: rm -rf %t -// RUN: %clang_cc1 -objcmt-migrate-readwrite-property -objcmt-migrate-instancetype -objcmt-white-list-dir-path=%S/Inputs %s -triple x86_64-apple-darwin11 -migrate -o %t.remap +// RUN: %clang_cc1 -objcmt-migrate-readwrite-property -objcmt-migrate-instancetype -objcmt-allowlist-dir-path=%S/Inputs %s -triple x86_64-apple-darwin11 -migrate -o %t.remap // RUN: c-arcmt-test %t.remap | arcmt-test -verify-transformed-files %S/header1.h.result %s.result @interface NSObject diff --git a/clang/test/ARCMT/whitelisted/objcmt-with-whitelist-impl.m.result b/clang/test/ARCMT/allowlisted/objcmt-with-allowlist-impl.m.result similarity index 75% rename from clang/test/ARCMT/whitelisted/objcmt-with-whitelist-impl.m.result rename to clang/test/ARCMT/allowlisted/objcmt-with-allowlist-impl.m.result index b936b52b729b..69e7b767ef2b 100644 --- a/clang/test/ARCMT/whitelisted/objcmt-with-whitelist-impl.m.result +++ b/clang/test/ARCMT/allowlisted/objcmt-with-allowlist-impl.m.result @@ -1,5 +1,5 @@ // RUN: rm -rf %t -// RUN: %clang_cc1 -objcmt-migrate-readwrite-property -objcmt-migrate-instancetype -objcmt-white-list-dir-path=%S/Inputs %s -triple x86_64-apple-darwin11 -migrate -o %t.remap +// RUN: %clang_cc1 -objcmt-migrate-readwrite-property -objcmt-migrate-instancetype -objcmt-allowlist-dir-path=%S/Inputs %s -triple x86_64-apple-darwin11 -migrate -o %t.remap // RUN: c-arcmt-test %t.remap | arcmt-test -verify-transformed-files %S/header1.h.result %s.result @interface NSObject diff --git a/clang/test/ARCMT/whitelisted/objcmt-with-whitelist.m b/clang/test/ARCMT/allowlisted/objcmt-with-allowlist.m similarity index 79% rename from clang/test/ARCMT/whitelisted/objcmt-with-whitelist.m rename to clang/test/ARCMT/allowlisted/objcmt-with-allowlist.m index 0ea714fe5937..c22c02d3bf2e 100644 --- a/clang/test/ARCMT/whitelisted/objcmt-with-whitelist.m +++ b/clang/test/ARCMT/allowlisted/objcmt-with-allowlist.m @@ -1,7 +1,7 @@ // RUN: rm -rf %t // RUN: %clang_cc1 -objcmt-migrate-readwrite-property -objcmt-migrate-instancetype -objcmt-migrate-ns-macros %s -triple x86_64-apple-darwin11 -migrate -o %t.remap // RUN: c-arcmt-test %t.remap | arcmt-test -verify-transformed-files %S/header1.h.result %S/header2.h.result -// RUN: %clang_cc1 -objcmt-migrate-readwrite-property -objcmt-migrate-instancetype -objcmt-migrate-ns-macros -objcmt-white-list-dir-path=%S/Inputs %s -triple x86_64-apple-darwin11 -migrate -o %t.remap +// RUN: %clang_cc1 -objcmt-migrate-readwrite-property -objcmt-migrate-instancetype -objcmt-migrate-ns-macros -objcmt-allowlist-dir-path=%S/Inputs %s -triple x86_64-apple-darwin11 -migrate -o %t.remap // RUN: c-arcmt-test %t.remap | arcmt-test -verify-transformed-files %S/header1.h.result @interface NSObject diff --git a/clang/test/SemaObjC/method-conflict-1.m b/clang/test/SemaObjC/method-conflict-1.m index 654cd0166fb5..03178fcada3e 100644 --- a/clang/test/SemaObjC/method-conflict-1.m +++ b/clang/test/SemaObjC/method-conflict-1.m @@ -73,7 +73,7 @@ - (A*) test2 { return 0; } // broken-warning {{conflicting return type in implementation of 'test2': 'B *' vs 'A *'}} @end -// The particular case of overriding with an id return is white-listed. +// The particular case of overriding with an id return is permitted. @interface Test4 {} - (id) test1; - (A*) test2; diff --git a/clang/test/SemaObjC/method-conflict-2.m b/clang/test/SemaObjC/method-conflict-2.m index 47c3d6c2c23c..65f0d5534e07 100644 --- a/clang/test/SemaObjC/method-conflict-2.m +++ b/clang/test/SemaObjC/method-conflict-2.m @@ -34,7 +34,7 @@ - (A*) test2 { return 0; } // expected-warning {{conflicting return type in implementation of 'test2': 'B *' vs 'A *'}} @end -// The particular case of overriding with an id return is white-listed. +// The particular case of overriding with an id return is permitted. @interface Test4 {} - (id) test1; - (A*) test2; diff --git a/clang/test/SemaObjC/method-typecheck-3.m b/clang/test/SemaObjC/method-typecheck-3.m index 1999b7d47702..a9e1f7a4f80b 100644 --- a/clang/test/SemaObjC/method-typecheck-3.m +++ b/clang/test/SemaObjC/method-typecheck-3.m @@ -13,7 +13,7 @@ @end @implementation B -- (id)obj {return self;} // 'id' overrides are white-listed? +- (id)obj {return self;} // 'id' overrides are permitted? - (A*)a { return self;} // expected-warning {{conflicting return type in implementation of 'a'}} - (void)takesA: (B*)a // expected-warning {{conflicting parameter types in implementation of 'takesA:'}} {}