[PATCH] D36580: [OpenCL] Support variable memory scope in atomic builtins
t-tye added inline comments. Comment at: include/clang/Basic/SyncScope.h:56 /// enums in opencl-c.h. -enum class SyncScope { - OpenCLWorkGroup = 1, - OpenCLDevice = 2, - OpenCLAllSVMDevices = 3, - OpenCLSubGroup = 4, +enum class OpenCLMemoryScope { + WorkGroup = 1, AtomicScopeOpenCLABI to mirror AtomicOrderingCABI? Comment at: include/clang/Basic/SyncScope.h:94 +/// and return a language-specific value. +inline bool isValidLanguageSyncScope(unsigned Scope) { + return Scope >= static_cast(OpenCLMemoryScope::WorkGroup) && Should this take a LangOpt since different languages may use different value ABIs? Comment at: lib/CodeGen/CGAtomic.cpp:678 + auto &Builder = CGF.Builder; + auto Scopes = getAllLanguageSyncScopes(); + llvm::DenseMap BB; Should only the scopes that apply to the language be returned otherwise will be generating code for invalid (possibly duplicate ABI) values? Comment at: lib/Frontend/InitPreprocessor.cpp:582 // The values should match clang SyncScope enum. - assert(static_cast(SyncScope::OpenCLWorkGroup) == 1 && - static_cast(SyncScope::OpenCLDevice) == 2 && - static_cast(SyncScope::OpenCLAllSVMDevices) == 3 && - static_cast(SyncScope::OpenCLSubGroup) == 4); + assert(static_cast(OpenCLMemoryScope::WorkGroup) == 1 && + static_cast(OpenCLMemoryScope::Device) == 2 && Could this be static_assert? https://reviews.llvm.org/D36580 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH]ast-dump: add -ast-dump-no-include option
Add an option, -ast-dump-no-include, to clang and clang-check. Usage example: clang++ -Xclang -ast-dump -Xclang -ast-dump-no-include -fsyntax-only test.cpp clang-check -ast-print -ast-dump-no-include test.cpp This option work with -ast-dump, -ast-dump-lookups or -ast-print to not show decls from included headers. This can be useful if you don't want decls from headers mess up ast-dump outputs. >From 45664657b1bcfedea3db1a3b187829c4028b1f00 Mon Sep 17 00:00:00 2001 From: Li Jinpei Date: Sun, 13 Aug 2017 18:51:57 +0800 Subject: [PATCH] add -ast-dump-no-include option MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="2.14.1" This is a multi-part message in MIME format. --2.14.1 Content-Type: text/plain; charset=UTF-8; format=fixed Content-Transfer-Encoding: 8bit --- include/clang/Driver/CC1Options.td| 3 ++ include/clang/Frontend/ASTConsumers.h | 6 ++- include/clang/Frontend/FrontendOptions.h | 2 + lib/Frontend/ASTConsumers.cpp | 63 +-- lib/Frontend/CompilerInvocation.cpp | 1 + lib/Frontend/FrontendActions.cpp | 6 ++- tools/clang-check/ClangCheck.cpp | 9 +++- tools/clang-import-test/clang-import-test.cpp | 2 +- 8 files changed, 62 insertions(+), 30 deletions(-) --2.14.1 Content-Type: text/x-patch; name="0001-add-ast-dump-no-include-option.patch" Content-Transfer-Encoding: 8bit Content-Disposition: attachment; filename="0001-add-ast-dump-no-include-option.patch" diff --git a/include/clang/Driver/CC1Options.td b/include/clang/Driver/CC1Options.td index 912abd9d48..275698d806 100644 --- a/include/clang/Driver/CC1Options.td +++ b/include/clang/Driver/CC1Options.td @@ -432,6 +432,9 @@ def ast_dump_filter : Separate<["-"], "ast-dump-filter">, HelpText<"Use with -ast-dump or -ast-print to dump/print only AST declaration" " nodes having a certain substring in a qualified name. Use" " -ast-list to list all filterable declaration node names.">; +def ast_dump_no_include : Flag<["-"], "ast-dump-no-include">, + HelpText<"Use with -ast-dump, -ast-dump-lookups or -ast-print," +" not show decls included from headers when dumping ASTs">; def fno_modules_global_index : Flag<["-"], "fno-modules-global-index">, HelpText<"Do not automatically generate or update the global module index">; def fno_modules_error_recovery : Flag<["-"], "fno-modules-error-recovery">, diff --git a/include/clang/Frontend/ASTConsumers.h b/include/clang/Frontend/ASTConsumers.h index 53975a07ea..0f39f1a8a1 100644 --- a/include/clang/Frontend/ASTConsumers.h +++ b/include/clang/Frontend/ASTConsumers.h @@ -32,13 +32,15 @@ class TargetOptions; // clang could re-parse the output back into the same AST, but the // implementation is still incomplete. std::unique_ptr CreateASTPrinter(std::unique_ptr OS, - StringRef FilterString); + StringRef FilterString, + bool NoInclude = false); // AST dumper: dumps the raw AST in human-readable form to stderr; this is // intended for debugging. std::unique_ptr CreateASTDumper(StringRef FilterString, bool DumpDecls, bool Deserialize, - bool DumpLookups); + bool DumpLookups, + bool NoInclude = false); // AST Decl node lister: prints qualified names of all filterable AST Decl // nodes. diff --git a/include/clang/Frontend/FrontendOptions.h b/include/clang/Frontend/FrontendOptions.h index e757a7e397..f31f4d842f 100644 --- a/include/clang/Frontend/FrontendOptions.h +++ b/include/clang/Frontend/FrontendOptions.h @@ -196,6 +196,8 @@ public: ///< when forming AST dumps. unsigned ASTDumpLookups : 1; ///< Whether we include lookup table ///< dumps in AST dumps. + unsigned ASTDumpNoInclude : 1; ///< Whether not to include decls + ///< from included headers in AST dumps. unsigned BuildingImplicitModule : 1; ///< Whether we are performing an ///< implicit module build. unsigned ModulesEmbedAllFiles : 1; ///< Whether we should embed all used diff --git a/lib/Frontend/ASTConsumers.cpp b/lib/Frontend/ASTConsumers.cpp index 7dc475e26f..8dfd53913b 100644 --- a/lib/Frontend/ASTConsumers.cpp +++ b/lib/Frontend/ASTConsumers.cpp @@ -35,19 +35,25 @@ namespace { public: enum Kind { DumpFull, Dump, Print, None }; -ASTPrinter(std::unique_ptr Out, Kind K, StringRef FilterString, - bool DumpLookups = false) -: Out(Out ? *Out : llvm::outs()), OwnedOut(std::move(Out)), -
[PATCH] D36580: [OpenCL] Support variable memory scope in atomic builtins
yaxunl marked 8 inline comments as done. yaxunl added inline comments. Comment at: include/clang/Basic/SyncScope.h:56 /// enums in opencl-c.h. -enum class SyncScope { - OpenCLWorkGroup = 1, - OpenCLDevice = 2, - OpenCLAllSVMDevices = 3, - OpenCLSubGroup = 4, +enum class OpenCLMemoryScope { + WorkGroup = 1, t-tye wrote: > AtomicScopeOpenCLABI to mirror AtomicOrderingCABI? Will do. Comment at: include/clang/Basic/SyncScope.h:94 +/// and return a language-specific value. +inline bool isValidLanguageSyncScope(unsigned Scope) { + return Scope >= static_cast(OpenCLMemoryScope::WorkGroup) && t-tye wrote: > Should this take a LangOpt since different languages may use different value > ABIs? Although currently this function does not use LangOpt, but I agree it may be a good idea to make it future proof. Will add it and update comment. Comment at: lib/CodeGen/CGAtomic.cpp:678 + auto &Builder = CGF.Builder; + auto Scopes = getAllLanguageSyncScopes(); + llvm::DenseMap BB; t-tye wrote: > Should only the scopes that apply to the language be returned otherwise will > be generating code for invalid (possibly duplicate ABI) values? getAllLanguageSyncScopes() only returns scope values for current language. I will rename it to getRuntimeSyncScopeValuesForCurrentLanguage() to avoid confusing. https://reviews.llvm.org/D36580 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D35678: Omit sumbodule semantics for TS modules
boris updated this revision to Diff 110875. boris added a comment. Richard, sorry for the last ping, somehow I missed your review. I've uploaded a new revision with a test case (note that the issue is with 'module a.b' not 'import a.b' but I have tested both for good measure). My understanding of your comment is that the rest is ok for now (since there will probably be a redesign in this area). If, however, I misunderstood and you sill want to move the id flattening to the caller, let me know. https://reviews.llvm.org/D35678 Files: lib/Frontend/CompilerInstance.cpp test/CXX/modules-ts/dcl.dcl/dcl.module/dcl.module.import/p1.cpp Index: test/CXX/modules-ts/dcl.dcl/dcl.module/dcl.module.import/p1.cpp === --- test/CXX/modules-ts/dcl.dcl/dcl.module/dcl.module.import/p1.cpp +++ test/CXX/modules-ts/dcl.dcl/dcl.module/dcl.module.import/p1.cpp @@ -2,13 +2,17 @@ // RUN: mkdir -p %t // RUN: echo 'export module x; export int a, b;' > %t/x.cppm // RUN: echo 'export module x.y; export int c;' > %t/x.y.cppm +// RUN: echo 'export module a.b; export int d;' > %t/a.b.cppm // // RUN: %clang_cc1 -std=c++1z -fmodules-ts -emit-module-interface %t/x.cppm -o %t/x.pcm // RUN: %clang_cc1 -std=c++1z -fmodules-ts -emit-module-interface -fmodule-file=%t/x.pcm %t/x.y.cppm -o %t/x.y.pcm +// RUN: %clang_cc1 -std=c++1z -fmodules-ts -emit-module-interface %t/a.b.cppm -o %t/a.b.pcm // -// RUN: %clang_cc1 -std=c++1z -fmodules-ts -I%t -fmodule-file=%t/x.y.pcm -verify %s \ +// RUN: %clang_cc1 -std=c++1z -fmodules-ts -I%t -fmodule-file=%t/x.y.pcm -fmodule-file=%t/a.b.pcm -verify %s \ // RUN:-DMODULE_NAME=z -// RUN: %clang_cc1 -std=c++1z -fmodules-ts -I%t -fmodule-file=%t/x.y.pcm -verify %s \ +// RUN: %clang_cc1 -std=c++1z -fmodules-ts -I%t -fmodule-file=%t/x.y.pcm -fmodule-file=%t/a.b.pcm -verify %s \ +// RUN:-DMODULE_NAME=a.b +// RUN: %clang_cc1 -std=c++1z -fmodules-ts -I%t -fmodule-file=%t/x.y.pcm -fmodule-file=%t/a.b.pcm -verify %s \ // RUN:-DMODULE_X -DMODULE_NAME=x module MODULE_NAME; @@ -33,6 +37,7 @@ import x [[blarg::noreturn]]; // expected-warning {{unknown attribute 'noreturn' ignored}} import x.y; +import a.b; // Does not imply existence of module a. import x.; // expected-error {{expected a module name after 'import'}} import .x; // expected-error {{expected a module name after 'import'}} Index: lib/Frontend/CompilerInstance.cpp === --- lib/Frontend/CompilerInstance.cpp +++ lib/Frontend/CompilerInstance.cpp @@ -1601,7 +1601,22 @@ Module::NameVisibilityKind Visibility, bool IsInclusionDirective) { // Determine what file we're searching from. - StringRef ModuleName = Path[0].first->getName(); + // FIXME: Should we be deciding whether this is a submodule (here and + // below) based on -fmodules-ts or should we pass a flag and make the + // caller decide? + std::string ModuleName; + if (getLangOpts().ModulesTS) { +// FIXME: Same code as Sema::ActOnModuleDecl() so there is probably a +// better place/way to do this. +for (auto &Piece : Path) { + if (!ModuleName.empty()) +ModuleName += "."; + ModuleName += Piece.first->getName(); +} + } + else +ModuleName = Path[0].first->getName(); + SourceLocation ModuleNameLoc = Path[0].second; // If we've already handled this import, just return the cached result. @@ -1816,7 +1831,7 @@ // Verify that the rest of the module path actually corresponds to // a submodule. - if (Path.size() > 1) { + if (!getLangOpts().ModulesTS && Path.size() > 1) { for (unsigned I = 1, N = Path.size(); I != N; ++I) { StringRef Name = Path[I].first->getName(); clang::Module *Sub = Module->findSubmodule(Name); Index: test/CXX/modules-ts/dcl.dcl/dcl.module/dcl.module.import/p1.cpp === --- test/CXX/modules-ts/dcl.dcl/dcl.module/dcl.module.import/p1.cpp +++ test/CXX/modules-ts/dcl.dcl/dcl.module/dcl.module.import/p1.cpp @@ -2,13 +2,17 @@ // RUN: mkdir -p %t // RUN: echo 'export module x; export int a, b;' > %t/x.cppm // RUN: echo 'export module x.y; export int c;' > %t/x.y.cppm +// RUN: echo 'export module a.b; export int d;' > %t/a.b.cppm // // RUN: %clang_cc1 -std=c++1z -fmodules-ts -emit-module-interface %t/x.cppm -o %t/x.pcm // RUN: %clang_cc1 -std=c++1z -fmodules-ts -emit-module-interface -fmodule-file=%t/x.pcm %t/x.y.cppm -o %t/x.y.pcm +// RUN: %clang_cc1 -std=c++1z -fmodules-ts -emit-module-interface %t/a.b.cppm -o %t/a.b.pcm // -// RUN: %clang_cc1 -std=c++1z -fmodules-ts -I%t -fmodule-file=%t/x.y.pcm -verify %s \ +// RUN: %clang_cc1 -std=c++1z -fmodules-ts -I%t -fmodule-file=%t/x.y.pcm -fmodule-file=%t/a.b.pcm -verify %s \ // RUN:-DMODULE_NAME=z -// RUN: %clang_cc1 -std=c++1z -fmodules-ts
[PATCH] D36572: Implemented P0409R2 - Allow lambda capture [=, this]
faisalv added inline comments. Comment at: lib/Sema/SemaLambda.cpp:959 + ? diag::ext_equals_this_lambda_capture_cxx2a + : diag::warn_cxx1z_compat_equals_this_lambda_capture); Shouldn't we try and hit the 'continue' (that u deleted) if warnings (and extension warnings) are turned into errors? Comment at: test/SemaCXX/cxx2a-lambda-equals-this.cpp:6 +// Deleting the copy constructor ensures that an [=, this] capture doesn't copy the object. +// Accessing a member variable from the lambda ensures that the capture actually works. +class A { Nice - I wish we had (and that I had placed) more comments such as these in our test files :) https://reviews.llvm.org/D36572 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D36572: Implemented P0409R2 - Allow lambda capture [=, this]
hamzasood added inline comments. Comment at: lib/Sema/SemaLambda.cpp:959 + ? diag::ext_equals_this_lambda_capture_cxx2a + : diag::warn_cxx1z_compat_equals_this_lambda_capture); faisalv wrote: > Shouldn't we try and hit the 'continue' (that u deleted) if warnings (and > extension warnings) are turned into errors? That's an interesting scenario which admittedly I hadn't considered. I based this implementation on the [[ https://github.com/llvm-mirror/clang/blob/7602b13a8e8b5656afd6327d112b76b39f836e5b/lib/Sema/SemaLambda.cpp#L935 | '*this' capture handling ]] from the same loop. When a '*this' capture is seen pre-C++1z, an extension warning is emitted and then the capture is processed as normal (i.e. without consideration of that warning potentially becoming an error). I also looked at other places where extension warnings are emitted and I couldn't find any special handling for warnings becoming errors. https://reviews.llvm.org/D36572 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D36572: Implemented P0409R2 - Allow lambda capture [=, this]
faisalv accepted this revision. faisalv added a comment. This revision is now accepted and ready to land. OK - looks good enough to me. I say we give the rest of the reviewers until friday to chime in, and if no one blocks it, can you commit then? nice work - thanks! https://reviews.llvm.org/D36572 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D36364: [AArch64] Add support for a MinGW AArch64 target
compnerd accepted this revision. compnerd added a comment. Yeah, I think that this is okay. https://reviews.llvm.org/D36364 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D36580: [OpenCL] Support variable memory scope in atomic builtins
t-tye added inline comments. Comment at: lib/CodeGen/CGAtomic.cpp:678 + auto &Builder = CGF.Builder; + auto Scopes = getAllLanguageSyncScopes(); + llvm::DenseMap BB; yaxunl wrote: > t-tye wrote: > > Should only the scopes that apply to the language be returned otherwise > > will be generating code for invalid (possibly duplicate ABI) values? > getAllLanguageSyncScopes() only returns scope values for current language. I > will rename it to getRuntimeSyncScopeValuesForCurrentLanguage() to avoid > confusing. Curretly getAllLanguageSyncScopes does not take a LangOpt so not sure how it knows what the language is, and did not see it checking that the language is OpenCL internally. For non-OpenCL languages do they still have to support system scope? https://reviews.llvm.org/D36580 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r310798 - [AArch64] Add support for a MinGW AArch64 target
Author: mstorsjo Date: Sun Aug 13 12:42:17 2017 New Revision: 310798 URL: http://llvm.org/viewvc/llvm-project?rev=310798&view=rev Log: [AArch64] Add support for a MinGW AArch64 target Differential Revision: https://reviews.llvm.org/D36364 Modified: cfe/trunk/lib/Basic/Targets.cpp cfe/trunk/lib/Basic/Targets/AArch64.cpp cfe/trunk/lib/Basic/Targets/AArch64.h cfe/trunk/lib/Driver/ToolChains/CrossWindows.cpp cfe/trunk/lib/Driver/ToolChains/MinGW.cpp cfe/trunk/test/Preprocessor/predefined-macros.c Modified: cfe/trunk/lib/Basic/Targets.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets.cpp?rev=310798&r1=310797&r2=310798&view=diff == --- cfe/trunk/lib/Basic/Targets.cpp (original) +++ cfe/trunk/lib/Basic/Targets.cpp Sun Aug 13 12:42:17 2017 @@ -142,7 +142,13 @@ TargetInfo *AllocateTarget(const llvm::T case llvm::Triple::OpenBSD: return new OpenBSDTargetInfo(Triple, Opts); case llvm::Triple::Win32: - return new MicrosoftARM64TargetInfo(Triple, Opts); + switch (Triple.getEnvironment()) { + case llvm::Triple::GNU: +return new MinGWARM64TargetInfo(Triple, Opts); + case llvm::Triple::MSVC: + default: // Assume MSVC for unknown environments +return new MicrosoftARM64TargetInfo(Triple, Opts); + } default: return new AArch64leTargetInfo(Triple, Opts); } Modified: cfe/trunk/lib/Basic/Targets/AArch64.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets/AArch64.cpp?rev=310798&r1=310797&r2=310798&view=diff == --- cfe/trunk/lib/Basic/Targets/AArch64.cpp (original) +++ cfe/trunk/lib/Basic/Targets/AArch64.cpp Sun Aug 13 12:42:17 2017 @@ -414,8 +414,8 @@ void AArch64beTargetInfo::setDataLayout( resetDataLayout("E-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128"); } -MicrosoftARM64TargetInfo::MicrosoftARM64TargetInfo(const llvm::Triple &Triple, - const TargetOptions &Opts) +WindowsARM64TargetInfo::WindowsARM64TargetInfo(const llvm::Triple &Triple, + const TargetOptions &Opts) : WindowsTargetInfo(Triple, Opts), Triple(Triple) { // This is an LLP64 platform. @@ -431,35 +431,19 @@ MicrosoftARM64TargetInfo::MicrosoftARM64 SizeType = UnsignedLongLong; PtrDiffType = SignedLongLong; IntPtrType = SignedLongLong; - - TheCXXABI.set(TargetCXXABI::Microsoft); } -void MicrosoftARM64TargetInfo::setDataLayout() { +void WindowsARM64TargetInfo::setDataLayout() { resetDataLayout("e-m:w-p:64:64-i32:32-i64:64-i128:128-n32:64-S128"); } -void MicrosoftARM64TargetInfo::getVisualStudioDefines( -const LangOptions &Opts, MacroBuilder &Builder) const { - WindowsTargetInfo::getVisualStudioDefines(Opts, Builder); - Builder.defineMacro("_WIN32", "1"); - Builder.defineMacro("_WIN64", "1"); - Builder.defineMacro("_M_ARM64", "1"); -} - -void MicrosoftARM64TargetInfo::getTargetDefines(const LangOptions &Opts, -MacroBuilder &Builder) const { - WindowsTargetInfo::getTargetDefines(Opts, Builder); - getVisualStudioDefines(Opts, Builder); -} - TargetInfo::BuiltinVaListKind -MicrosoftARM64TargetInfo::getBuiltinVaListKind() const { +WindowsARM64TargetInfo::getBuiltinVaListKind() const { return TargetInfo::CharPtrBuiltinVaList; } TargetInfo::CallingConvCheckResult -MicrosoftARM64TargetInfo::checkCallingConvention(CallingConv CC) const { +WindowsARM64TargetInfo::checkCallingConvention(CallingConv CC) const { switch (CC) { case CC_X86StdCall: case CC_X86ThisCall: @@ -475,6 +459,43 @@ MicrosoftARM64TargetInfo::checkCallingCo } } +MicrosoftARM64TargetInfo::MicrosoftARM64TargetInfo(const llvm::Triple &Triple, + const TargetOptions &Opts) +: WindowsARM64TargetInfo(Triple, Opts) { + TheCXXABI.set(TargetCXXABI::Microsoft); +} + +void MicrosoftARM64TargetInfo::getVisualStudioDefines( +const LangOptions &Opts, MacroBuilder &Builder) const { + WindowsTargetInfo::getVisualStudioDefines(Opts, Builder); + Builder.defineMacro("_WIN32", "1"); + Builder.defineMacro("_WIN64", "1"); + Builder.defineMacro("_M_ARM64", "1"); +} + +void MicrosoftARM64TargetInfo::getTargetDefines(const LangOptions &Opts, +MacroBuilder &Builder) const { + WindowsTargetInfo::getTargetDefines(Opts, Builder); + getVisualStudioDefines(Opts, Builder); +} + +MinGWARM64TargetInfo::MinGWARM64TargetInfo(const llvm::Triple &Triple, + const TargetOptions &Opts) +: WindowsARM64TargetInfo(Triple, Opts) { + TheCXXABI.set(TargetCXXABI::GenericAArch64); +} + +void MinGWARM64TargetInfo::getTargetDefines(const LangOptions &Opts, +
[PATCH] D36364: [AArch64] Add support for a MinGW AArch64 target
This revision was automatically updated to reflect the committed changes. Closed by commit rL310798: [AArch64] Add support for a MinGW AArch64 target (authored by mstorsjo). Changed prior to commit: https://reviews.llvm.org/D36364?vs=109935&id=110886#toc Repository: rL LLVM https://reviews.llvm.org/D36364 Files: cfe/trunk/lib/Basic/Targets.cpp cfe/trunk/lib/Basic/Targets/AArch64.cpp cfe/trunk/lib/Basic/Targets/AArch64.h cfe/trunk/lib/Driver/ToolChains/CrossWindows.cpp cfe/trunk/lib/Driver/ToolChains/MinGW.cpp cfe/trunk/test/Preprocessor/predefined-macros.c Index: cfe/trunk/lib/Driver/ToolChains/CrossWindows.cpp === --- cfe/trunk/lib/Driver/ToolChains/CrossWindows.cpp +++ cfe/trunk/lib/Driver/ToolChains/CrossWindows.cpp @@ -36,6 +36,7 @@ llvm_unreachable("unsupported architecture"); case llvm::Triple::arm: case llvm::Triple::thumb: + case llvm::Triple::aarch64: break; case llvm::Triple::x86: CmdArgs.push_back("--32"); @@ -98,6 +99,9 @@ // FIXME: this is incorrect for WinCE CmdArgs.push_back("thumb2pe"); break; + case llvm::Triple::aarch64: +CmdArgs.push_back("arm64pe"); +break; case llvm::Triple::x86: CmdArgs.push_back("i386pe"); EntryPoint.append("_"); @@ -111,6 +115,7 @@ switch (T.getArch()) { default: llvm_unreachable("unsupported architecture"); +case llvm::Triple::aarch64: case llvm::Triple::arm: case llvm::Triple::thumb: case llvm::Triple::x86_64: Index: cfe/trunk/lib/Driver/ToolChains/MinGW.cpp === --- cfe/trunk/lib/Driver/ToolChains/MinGW.cpp +++ cfe/trunk/lib/Driver/ToolChains/MinGW.cpp @@ -119,12 +119,24 @@ CmdArgs.push_back("-s"); CmdArgs.push_back("-m"); - if (TC.getArch() == llvm::Triple::x86) + switch (TC.getArch()) { + case llvm::Triple::x86: CmdArgs.push_back("i386pe"); - if (TC.getArch() == llvm::Triple::x86_64) +break; + case llvm::Triple::x86_64: CmdArgs.push_back("i386pep"); - if (TC.getArch() == llvm::Triple::arm) +break; + case llvm::Triple::arm: + case llvm::Triple::thumb: +// FIXME: this is incorrect for WinCE CmdArgs.push_back("thumb2pe"); +break; + case llvm::Triple::aarch64: +CmdArgs.push_back("arm64pe"); +break; + default: +llvm_unreachable("Unsupported target architecture."); + } if (Args.hasArg(options::OPT_mwindows)) { CmdArgs.push_back("--subsystem"); Index: cfe/trunk/lib/Basic/Targets/AArch64.h === --- cfe/trunk/lib/Basic/Targets/AArch64.h +++ cfe/trunk/lib/Basic/Targets/AArch64.h @@ -89,24 +89,42 @@ void setDataLayout() override; }; -class LLVM_LIBRARY_VISIBILITY MicrosoftARM64TargetInfo +class LLVM_LIBRARY_VISIBILITY WindowsARM64TargetInfo : public WindowsTargetInfo { const llvm::Triple Triple; public: - MicrosoftARM64TargetInfo(const llvm::Triple &Triple, - const TargetOptions &Opts); + WindowsARM64TargetInfo(const llvm::Triple &Triple, + const TargetOptions &Opts); void setDataLayout() override; + BuiltinVaListKind getBuiltinVaListKind() const override; + + CallingConvCheckResult checkCallingConvention(CallingConv CC) const override; +}; + +// Windows ARM, MS (C++) ABI +class LLVM_LIBRARY_VISIBILITY MicrosoftARM64TargetInfo +: public WindowsARM64TargetInfo { +public: + MicrosoftARM64TargetInfo(const llvm::Triple &Triple, + const TargetOptions &Opts); + void getVisualStudioDefines(const LangOptions &Opts, MacroBuilder &Builder) const; void getTargetDefines(const LangOptions &Opts, MacroBuilder &Builder) const override; +}; - BuiltinVaListKind getBuiltinVaListKind() const override; +// ARM64 MinGW target +class LLVM_LIBRARY_VISIBILITY MinGWARM64TargetInfo +: public WindowsARM64TargetInfo { +public: + MinGWARM64TargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts); - CallingConvCheckResult checkCallingConvention(CallingConv CC) const override; + void getTargetDefines(const LangOptions &Opts, +MacroBuilder &Builder) const override; }; class LLVM_LIBRARY_VISIBILITY AArch64beTargetInfo : public AArch64TargetInfo { Index: cfe/trunk/lib/Basic/Targets/AArch64.cpp === --- cfe/trunk/lib/Basic/Targets/AArch64.cpp +++ cfe/trunk/lib/Basic/Targets/AArch64.cpp @@ -414,8 +414,8 @@ resetDataLayout("E-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128"); } -MicrosoftARM64TargetInfo::MicrosoftARM64TargetInfo(const llvm::Triple &Triple, - const TargetOptions &Opts) +WindowsARM64TargetInfo::WindowsARM64TargetInfo(const llvm::Triple &Triple, +
r310803 - [c++2a] Treat 'concept' and 'requires' as keywords, add compat warning for C++17 and before.
Author: rsmith Date: Sun Aug 13 14:32:33 2017 New Revision: 310803 URL: http://llvm.org/viewvc/llvm-project?rev=310803&view=rev Log: [c++2a] Treat 'concept' and 'requires' as keywords, add compat warning for C++17 and before. Modified: cfe/trunk/include/clang/Basic/DiagnosticGroups.td cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td cfe/trunk/include/clang/Basic/TokenKinds.def cfe/trunk/lib/Basic/IdentifierTable.cpp cfe/trunk/lib/Lex/Preprocessor.cpp cfe/trunk/test/Lexer/keywords_test.cpp Modified: cfe/trunk/include/clang/Basic/DiagnosticGroups.td URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticGroups.td?rev=310803&r1=310802&r2=310803&view=diff == --- cfe/trunk/include/clang/Basic/DiagnosticGroups.td (original) +++ cfe/trunk/include/clang/Basic/DiagnosticGroups.td Sun Aug 13 14:32:33 2017 @@ -224,6 +224,8 @@ def CXX1zCompat : DiagGroup<"c++1z-compa DeprecatedIncrementBool, CXX1zCompatMangling]>; +def CXX2aCompat : DiagGroup<"c++2a-compat">; + def ExitTimeDestructors : DiagGroup<"exit-time-destructors">; def FlexibleArrayExtensions : DiagGroup<"flexible-array-extensions">; def FourByteMultiChar : DiagGroup<"four-char-constants">; Modified: cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td?rev=310803&r1=310802&r2=310803&view=diff == --- cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td (original) +++ cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td Sun Aug 13 14:32:33 2017 @@ -71,6 +71,8 @@ def ext_token_used : Extension<"extensio def warn_cxx11_keyword : Warning<"'%0' is a keyword in C++11">, InGroup, DefaultIgnore; +def warn_cxx2a_keyword : Warning<"'%0' is a keyword in C++2a">, + InGroup, DefaultIgnore; def ext_unterminated_char_or_string : ExtWarn< "missing terminating %select{'|'\"'}0 character">, InGroup; Modified: cfe/trunk/include/clang/Basic/TokenKinds.def URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/TokenKinds.def?rev=310803&r1=310802&r2=310803&view=diff == --- cfe/trunk/include/clang/Basic/TokenKinds.def (original) +++ cfe/trunk/include/clang/Basic/TokenKinds.def Sun Aug 13 14:32:33 2017 @@ -27,8 +27,11 @@ #ifndef CXX11_KEYWORD #define CXX11_KEYWORD(X,Y) KEYWORD(X,KEYCXX11|(Y)) #endif +#ifndef CXX2A_KEYWORD +#define CXX2A_KEYWORD(X,Y) KEYWORD(X,KEYCXX2A|(Y)) +#endif #ifndef CONCEPTS_KEYWORD -#define CONCEPTS_KEYWORD(X) KEYWORD(X,KEYCONCEPTS) +#define CONCEPTS_KEYWORD(X) CXX2A_KEYWORD(X,KEYCONCEPTS) #endif #ifndef MODULES_KEYWORD #define MODULES_KEYWORD(X) KEYWORD(X,KEYMODULES) @@ -236,6 +239,7 @@ PUNCTUATOR(caretcaret,"^^") // implementation namespace // KEYNOCXX - This is a keyword in every non-C++ dialect. // KEYCXX11 - This is a C++ keyword introduced to C++ in C++11 +// KEYCXX2A - This is a C++ keyword introduced to C++ in C++2a // KEYCONCEPTS - This is a keyword if the C++ extensions for concepts // are enabled. // KEYMODULES - This is a keyword if the C++ extensions for modules @@ -362,7 +366,7 @@ CXX11_KEYWORD(nullptr , 0) CXX11_KEYWORD(static_assert , 0) CXX11_KEYWORD(thread_local , 0) -// C++ concepts TS keywords +// C++2a / concepts TS keywords CONCEPTS_KEYWORD(concept) CONCEPTS_KEYWORD(requires) @@ -810,6 +814,7 @@ ANNOTATION(module_end) #undef TYPE_TRAIT_1 #undef TYPE_TRAIT #undef CONCEPTS_KEYWORD +#undef CXX2A_KEYWORD #undef CXX11_KEYWORD #undef KEYWORD #undef PUNCTUATOR Modified: cfe/trunk/lib/Basic/IdentifierTable.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/IdentifierTable.cpp?rev=310803&r1=310802&r2=310803&view=diff == --- cfe/trunk/lib/Basic/IdentifierTable.cpp (original) +++ cfe/trunk/lib/Basic/IdentifierTable.cpp Sun Aug 13 14:32:33 2017 @@ -114,7 +114,9 @@ namespace { KEYZVECTOR = 0x4, KEYCOROUTINES = 0x8, KEYMODULES = 0x10, -KEYALL = (0x1f & ~KEYNOMS18 & +KEYCXX2A = 0x20, +KEYALLCXX = KEYCXX | KEYCXX11 | KEYCXX2A, +KEYALL = (0x3f & ~KEYNOMS18 & ~KEYNOOPENCL) // KEYNOMS18 and KEYNOOPENCL are used to exclude. }; @@ -134,6 +136,7 @@ static KeywordStatus getKeywordStatus(co if (Flags == KEYALL) return KS_Enabled; if (LangOpts.CPlusPlus && (Flags & KEYCXX)) return KS_Enabled; if (LangOpts.CPlusPlus11 && (Flags & KEYCXX11)) return KS_Enabled; + if (LangOpts.CPlusPlus2a && (Flags & KEYCXX2A)) return KS_Enabled; if (LangOpts.C99 && (Flags & KEYC99)) return KS_Enabled;
r310804 - Replace remaining user-visible mentions of C++1z with C++17.
Author: rsmith Date: Sun Aug 13 15:26:53 2017 New Revision: 310804 URL: http://llvm.org/viewvc/llvm-project?rev=310804&view=rev Log: Replace remaining user-visible mentions of C++1z with C++17. Modified: cfe/trunk/include/clang/Basic/DiagnosticGroups.td cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td cfe/trunk/test/CXX/dcl.dcl/dcl.attr/dcl.attr.nodiscard/p2.cpp cfe/trunk/test/CXX/dcl.dcl/dcl.attr/dcl.attr.unused/p3.cpp cfe/trunk/test/CXX/drs/dr0xx.cpp cfe/trunk/test/CXX/drs/dr13xx.cpp cfe/trunk/test/CXX/drs/dr1xx.cpp cfe/trunk/test/CXX/drs/dr2xx.cpp cfe/trunk/test/CXX/drs/dr4xx.cpp cfe/trunk/test/CXX/drs/dr5xx.cpp cfe/trunk/test/CXX/stmt.stmt/stmt.iter/stmt.ranged/p1.cpp cfe/trunk/test/FixIt/fixit.cpp cfe/trunk/test/Lexer/hexfloat.cpp cfe/trunk/test/Parser/cxx0x-attributes.cpp cfe/trunk/test/Parser/cxx1z-constexpr-lambdas.cpp cfe/trunk/test/Parser/cxx1z-nested-namespace-definition.cpp cfe/trunk/test/SemaCXX/cxx0x-compat.cpp cfe/trunk/test/SemaCXX/deprecated.cpp cfe/trunk/test/SemaCXX/inline.cpp cfe/trunk/test/SemaCXX/static-assert.cpp cfe/trunk/test/SemaCXX/warn-c++1z-extensions.cpp cfe/trunk/test/SemaTemplate/temp_arg_nontype_cxx11.cpp Modified: cfe/trunk/include/clang/Basic/DiagnosticGroups.td URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticGroups.td?rev=310804&r1=310803&r2=310804&view=diff == --- cfe/trunk/include/clang/Basic/DiagnosticGroups.td (original) +++ cfe/trunk/include/clang/Basic/DiagnosticGroups.td Sun Aug 13 15:26:53 2017 @@ -156,9 +156,10 @@ def FormatZeroLength : DiagGroup<"format def InvalidIOSDeploymentTarget : DiagGroup<"invalid-ios-deployment-target">; -def CXX1zCompatMangling : DiagGroup<"c++1z-compat-mangling">; +def CXX17CompatMangling : DiagGroup<"c++17-compat-mangling">; +def : DiagGroup<"c++1z-compat-mangling", [CXX17CompatMangling]>; // Name of this warning in GCC. -def NoexceptType : DiagGroup<"noexcept-type", [CXX1zCompatMangling]>; +def NoexceptType : DiagGroup<"noexcept-type", [CXX17CompatMangling]>; // Warnings for C++1y code which is not compatible with prior C++ standards. def CXXPre14Compat : DiagGroup<"c++98-c++11-compat">; @@ -220,9 +221,10 @@ def CXX14Compat : DiagGroup<"c++14-compa def CXX14CompatPedantic : DiagGroup<"c++14-compat-pedantic", [CXXPre1zCompatPedantic]>; -def CXX1zCompat : DiagGroup<"c++1z-compat", [DeprecatedRegister, +def CXX17Compat : DiagGroup<"c++17-compat", [DeprecatedRegister, DeprecatedIncrementBool, - CXX1zCompatMangling]>; + CXX17CompatMangling]>; +def : DiagGroup<"c++1z-compat", [CXX17Compat]>; def CXX2aCompat : DiagGroup<"c++2a-compat">; @@ -780,10 +782,11 @@ def CXX14 : DiagGroup<"c++14-extensions" // A warning group for warnings about using C++1z features as extensions in // earlier C++ versions. -def CXX1z : DiagGroup<"c++1z-extensions">; +def CXX17 : DiagGroup<"c++17-extensions">; def : DiagGroup<"c++0x-extensions", [CXX11]>; def : DiagGroup<"c++1y-extensions", [CXX14]>; +def : DiagGroup<"c++1z-extensions", [CXX17]>; def DelegatingCtorCycles : DiagGroup<"delegating-ctor-cycles">; Modified: cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td?rev=310804&r1=310803&r2=310804&view=diff == --- cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td (original) +++ cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td Sun Aug 13 15:26:53 2017 @@ -181,10 +181,10 @@ def err_hex_constant_requires : Error< def ext_hex_constant_invalid : Extension< "hexadecimal floating constants are a C99 feature">, InGroup; def ext_hex_literal_invalid : Extension< - "hexadecimal floating literals are a C++1z feature">, InGroup; + "hexadecimal floating literals are a C++17 feature">, InGroup; def warn_cxx1z_hex_literal : Warning< "hexadecimal floating literals are incompatible with " - "C++ standards before C++1z">, + "C++ standards before C++17">, InGroup, DefaultIgnore; def ext_binary_literal : Extension< "binary integer literals are a GNU extension">, InGroup; @@ -208,7 +208,7 @@ def warn_cxx98_compat_unicode_literal : "unicode literals are incompatible with C++98">, InGroup, DefaultIgnore; def warn_cxx14_compat_u8_character_literal : Warning< - "unicode literals are incompatible with C++ standards before C++1z">, + "unicode literals are incompatible with C++ standards before C++17">, InGroup, DefaultIgnore; def warn_cxx11_compat_user_defined_literal : War
Re: r310804 - Replace remaining user-visible mentions of C++1z with C++17.
Since we took the -std=c++17 change for Clang 5, we should take this one too. On 13 August 2017 at 15:26, Richard Smith via cfe-commits < cfe-commits@lists.llvm.org> wrote: > Author: rsmith > Date: Sun Aug 13 15:26:53 2017 > New Revision: 310804 > > URL: http://llvm.org/viewvc/llvm-project?rev=310804&view=rev > Log: > Replace remaining user-visible mentions of C++1z with C++17. > > Modified: > cfe/trunk/include/clang/Basic/DiagnosticGroups.td > cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td > cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td > cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td > cfe/trunk/test/CXX/dcl.dcl/dcl.attr/dcl.attr.nodiscard/p2.cpp > cfe/trunk/test/CXX/dcl.dcl/dcl.attr/dcl.attr.unused/p3.cpp > cfe/trunk/test/CXX/drs/dr0xx.cpp > cfe/trunk/test/CXX/drs/dr13xx.cpp > cfe/trunk/test/CXX/drs/dr1xx.cpp > cfe/trunk/test/CXX/drs/dr2xx.cpp > cfe/trunk/test/CXX/drs/dr4xx.cpp > cfe/trunk/test/CXX/drs/dr5xx.cpp > cfe/trunk/test/CXX/stmt.stmt/stmt.iter/stmt.ranged/p1.cpp > cfe/trunk/test/FixIt/fixit.cpp > cfe/trunk/test/Lexer/hexfloat.cpp > cfe/trunk/test/Parser/cxx0x-attributes.cpp > cfe/trunk/test/Parser/cxx1z-constexpr-lambdas.cpp > cfe/trunk/test/Parser/cxx1z-nested-namespace-definition.cpp > cfe/trunk/test/SemaCXX/cxx0x-compat.cpp > cfe/trunk/test/SemaCXX/deprecated.cpp > cfe/trunk/test/SemaCXX/inline.cpp > cfe/trunk/test/SemaCXX/static-assert.cpp > cfe/trunk/test/SemaCXX/warn-c++1z-extensions.cpp > cfe/trunk/test/SemaTemplate/temp_arg_nontype_cxx11.cpp > > Modified: cfe/trunk/include/clang/Basic/DiagnosticGroups.td > URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/ > clang/Basic/DiagnosticGroups.td?rev=310804&r1=310803&r2=310804&view=diff > > == > --- cfe/trunk/include/clang/Basic/DiagnosticGroups.td (original) > +++ cfe/trunk/include/clang/Basic/DiagnosticGroups.td Sun Aug 13 15:26:53 > 2017 > @@ -156,9 +156,10 @@ def FormatZeroLength : DiagGroup<"format > > def InvalidIOSDeploymentTarget : DiagGroup<"invalid-ios- > deployment-target">; > > -def CXX1zCompatMangling : DiagGroup<"c++1z-compat-mangling">; > +def CXX17CompatMangling : DiagGroup<"c++17-compat-mangling">; > +def : DiagGroup<"c++1z-compat-mangling", [CXX17CompatMangling]>; > // Name of this warning in GCC. > -def NoexceptType : DiagGroup<"noexcept-type", [CXX1zCompatMangling]>; > +def NoexceptType : DiagGroup<"noexcept-type", [CXX17CompatMangling]>; > > // Warnings for C++1y code which is not compatible with prior C++ > standards. > def CXXPre14Compat : DiagGroup<"c++98-c++11-compat">; > @@ -220,9 +221,10 @@ def CXX14Compat : DiagGroup<"c++14-compa > def CXX14CompatPedantic : DiagGroup<"c++14-compat-pedantic", > [CXXPre1zCompatPedantic]>; > > -def CXX1zCompat : DiagGroup<"c++1z-compat", [DeprecatedRegister, > +def CXX17Compat : DiagGroup<"c++17-compat", [DeprecatedRegister, > DeprecatedIncrementBool, > - CXX1zCompatMangling]>; > + CXX17CompatMangling]>; > +def : DiagGroup<"c++1z-compat", [CXX17Compat]>; > > def CXX2aCompat : DiagGroup<"c++2a-compat">; > > @@ -780,10 +782,11 @@ def CXX14 : DiagGroup<"c++14-extensions" > > // A warning group for warnings about using C++1z features as extensions > in > // earlier C++ versions. > -def CXX1z : DiagGroup<"c++1z-extensions">; > +def CXX17 : DiagGroup<"c++17-extensions">; > > def : DiagGroup<"c++0x-extensions", [CXX11]>; > def : DiagGroup<"c++1y-extensions", [CXX14]>; > +def : DiagGroup<"c++1z-extensions", [CXX17]>; > > def DelegatingCtorCycles : >DiagGroup<"delegating-ctor-cycles">; > > Modified: cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td > URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/ > DiagnosticLexKinds.td?rev=310804&r1=310803&r2=310804&view=diff > > == > --- cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td (original) > +++ cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td Sun Aug 13 > 15:26:53 2017 > @@ -181,10 +181,10 @@ def err_hex_constant_requires : Error< > def ext_hex_constant_invalid : Extension< >"hexadecimal floating constants are a C99 feature">, InGroup; > def ext_hex_literal_invalid : Extension< > - "hexadecimal floating literals are a C++1z feature">, InGroup; > + "hexadecimal floating literals are a C++17 feature">, InGroup; > def warn_cxx1z_hex_literal : Warning< >"hexadecimal floating literals are incompatible with " > - "C++ standards before C++1z">, > + "C++ standards before C++17">, >InGroup, DefaultIgnore; > def ext_binary_literal : Extension< >"binary integer literals are a GNU extension">, > InGroup; > @@ -208,7 +208,7 @@ def warn_cxx98_compat_un
r310805 - Rename cxx1z -> cxx17 across all diagnostic IDs.
Author: rsmith Date: Sun Aug 13 16:37:29 2017 New Revision: 310805 URL: http://llvm.org/viewvc/llvm-project?rev=310805&view=rev Log: Rename cxx1z -> cxx17 across all diagnostic IDs. Modified: cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td cfe/trunk/include/clang/Basic/LangOptions.def cfe/trunk/include/clang/Basic/TokenKinds.def cfe/trunk/lib/Lex/LiteralSupport.cpp cfe/trunk/lib/Parse/ParseDeclCXX.cpp cfe/trunk/lib/Parse/ParseExprCXX.cpp cfe/trunk/lib/Sema/SemaDecl.cpp cfe/trunk/lib/Sema/SemaDeclAttr.cpp cfe/trunk/lib/Sema/SemaLambda.cpp cfe/trunk/lib/Sema/SemaStmtAttr.cpp Modified: cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td?rev=310805&r1=310804&r2=310805&view=diff == --- cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td (original) +++ cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td Sun Aug 13 16:37:29 2017 @@ -182,7 +182,7 @@ def ext_hex_constant_invalid : Extension "hexadecimal floating constants are a C99 feature">, InGroup; def ext_hex_literal_invalid : Extension< "hexadecimal floating literals are a C++17 feature">, InGroup; -def warn_cxx1z_hex_literal : Warning< +def warn_cxx17_hex_literal : Warning< "hexadecimal floating literals are incompatible with " "C++ standards before C++17">, InGroup, DefaultIgnore; Modified: cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td?rev=310805&r1=310804&r2=310805&view=diff == --- cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td (original) +++ cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td Sun Aug 13 16:37:29 2017 @@ -752,13 +752,13 @@ def err_alias_declaration_pack_expansion def ext_multi_using_declaration : ExtWarn< "use of multiple declarators in a single using declaration is " "a C++17 extension">, InGroup; -def warn_cxx1z_compat_multi_using_declaration : Warning< +def warn_cxx17_compat_multi_using_declaration : Warning< "use of multiple declarators in a single using declaration is " "incompatible with C++ standards before C++17">, InGroup, DefaultIgnore; def ext_using_declaration_pack : ExtWarn< "pack expansion of using declaration is a C++17 extension">, InGroup; -def warn_cxx1z_compat_using_declaration_pack : Warning< +def warn_cxx17_compat_using_declaration_pack : Warning< "pack expansion using declaration is incompatible with C++ standards " "before C++17">, InGroup, DefaultIgnore; @@ -819,7 +819,7 @@ def err_expected_star_this_capture : Err def warn_cxx14_compat_constexpr_on_lambda : Warning< "constexpr on lambda expressions is incompatible with C++ standards before C++17">, InGroup, DefaultIgnore; -def ext_constexpr_on_lambda_cxx1z : ExtWarn< +def ext_constexpr_on_lambda_cxx17 : ExtWarn< "'constexpr' on lambda expressions is a C++17 extension">, InGroup; // Availability attribute Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=310805&r1=310804&r2=310805&view=diff == --- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original) +++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Sun Aug 13 16:37:29 2017 @@ -507,7 +507,7 @@ def warn_deprecated_copy_operation : War "for %0 is deprecated because it has a user-declared " "%select{copy %select{assignment operator|constructor}1|destructor}2">, InGroup, DefaultIgnore; -def warn_cxx1z_compat_exception_spec_in_signature : Warning< +def warn_cxx17_compat_exception_spec_in_signature : Warning< "mangled name of %0 will change in C++17 due to non-throwing exception " "specification in function signature">, InGroup; @@ -6556,7 +6556,7 @@ let CategoryName = "Lambda Issue" in { def warn_cxx14_compat_star_this_lambda_capture : Warning< "by value capture of '*this' is incompatible with C++ standards before C++17">, InGroup, DefaultIgnore; - def ext_star_this_lambda_capture_cxx1z : ExtWarn< + def ext_star_this_lambda_capture_cxx17 : ExtWarn< "capture of '*this' by copy is a C++17 extension">, InGroup; } @@ -7229,7 +7229,7 @@ def warn_unused_volatile : Warning< def ext_cxx14_attr : Extension< "use of the %0 attribute is a C++14 extension">, InGroup; -def ext_cxx1z_attr : Extension< +def ext_cxx17_attr : Extension< "use of the %0 attribute is a C++17 extension">, InGroup; def warn_unused_comparison : Warning< Modified: cfe/trunk/include/clang/Basic/LangOptions.def URL: http://llvm.org/viewv
[PATCH] D34275: [analyzer] Re-implemente current virtual calls checker in a path-sensitive way
wangxindsb updated this revision to Diff 110899. wangxindsb added a comment. Fix the Assertion Failed when run the checker to check the building of LibreOffice. https://reviews.llvm.org/D34275 Files: lib/StaticAnalyzer/Checkers/VirtualCallChecker.cpp test/Analysis/virtualcall.cpp Index: test/Analysis/virtualcall.cpp === --- test/Analysis/virtualcall.cpp +++ test/Analysis/virtualcall.cpp @@ -1,79 +1,43 @@ // RUN: %clang_analyze_cc1 -analyzer-checker=optin.cplusplus.VirtualCall -analyzer-store region -verify -std=c++11 %s -// RUN: %clang_analyze_cc1 -analyzer-checker=optin.cplusplus.VirtualCall -analyzer-store region -analyzer-config optin.cplusplus.VirtualCall:Interprocedural=true -DINTERPROCEDURAL=1 -verify -std=c++11 %s -// RUN: %clang_analyze_cc1 -analyzer-checker=optin.cplusplus.VirtualCall -analyzer-store region -analyzer-config optin.cplusplus.VirtualCall:PureOnly=true -DPUREONLY=1 -verify -std=c++11 %s -/* When INTERPROCEDURAL is set, we expect diagnostics in all functions reachable - from a constructor or destructor. If it is not set, we expect diagnostics - only in the constructor or destructor. - - When PUREONLY is set, we expect diagnostics only for calls to pure virtual - functions not to non-pure virtual functions. -*/ +// RUN: %clang_analyze_cc1 -analyzer-checker=optin.cplusplus.VirtualCall -analyzer-store region -analyzer-config optin.cplusplus.VirtualCall:PureOnly=true -DPUREONLY=1 -verify -std=c++11 %s class A { public: A(); - A(int i); ~A() {}; - virtual int foo() = 0; // from Sema: expected-note {{'foo' declared here}} - virtual void bar() = 0; + virtual int foo()=0; + virtual void bar()=0; void f() { foo(); -#if INTERPROCEDURAL -// expected-warning-re@-2 ^}}Call Path : foo <-- fCall to pure virtual function during construction has undefined behavior}} -#endif +// expected-warning:Call to virtual function during construction } }; class B : public A { public: B() { foo(); -#if !PUREONLY -#if INTERPROCEDURAL -// expected-warning-re@-3 ^}}Call Path : fooCall to virtual function during construction will not dispatch to derived class}} -#else -// expected-warning-re@-5 ^}}Call to virtual function during construction will not dispatch to derived class}} -#endif -#endif - +// expected-warning:Call to virtual function during construction } ~B(); virtual int foo(); virtual void bar() { foo(); } -#if INTERPROCEDURAL - // expected-warning-re@-2 ^}}Call Path : foo <-- barCall to virtual function during destruction will not dispatch to derived class}} -#endif + // expected-warning:Call to virtual function during destruction }; A::A() { f(); } -A::A(int i) { - foo(); // From Sema: expected-warning {{call to pure virtual member function 'foo' has undefined behavior}} -#if INTERPROCEDURAL - // expected-warning-re@-2 ^}}Call Path : fooCall to pure virtual function during construction has undefined behavior}} -#else - // expected-warning-re@-4 ^}}Call to pure virtual function during construction has undefined behavior}} -#endif -} - B::~B() { this->B::foo(); // no-warning this->B::bar(); this->foo(); -#if !PUREONLY -#if INTERPROCEDURAL - // expected-warning-re@-3 ^}}Call Path : fooCall to virtual function during destruction will not dispatch to derived class}} -#else - // expected-warning-re@-5 ^}}Call to virtual function during destruction will not dispatch to derived class}} -#endif -#endif - + // expected-warning:Call to virtual function during destruction } class C : public B { @@ -87,13 +51,7 @@ C::C() { f(foo()); -#if !PUREONLY -#if INTERPROCEDURAL - // expected-warning-re@-3 ^}}Call Path : fooCall to virtual function during construction will not dispatch to derived class}} -#else - // expected-warning-re@-5 ^}}Call to virtual function during construction will not dispatch to derived class}} -#endif -#endif + // expected-warning:Call to virtual function during construction } class D : public B { @@ -103,7 +61,8 @@ } ~D() { bar(); } int foo() final; - void bar() final { foo(); } // no-warning + void bar() final { foo(); } + // no-warning }; class E final : public B { @@ -115,7 +74,6 @@ int foo() override; }; -// Regression test: don't crash when there's no direct callee. class F { public: F() { @@ -125,17 +83,103 @@ void foo(); }; -int main() { - A *a; - B *b; - C *c; - D *d; - E *e; - F *f; +class G { +public: + G() {} + virtual void bar(); + void foo() { +bar(); + // no warning + } +}; + +class H{ +public: + H() : initState(0) { init(); } + int initState; + virtual void f() const; + void init() { +if (initState) + f(); + // no warning + } + + H(int i) { +G g; +g.foo(); +g.bar(); + // no warning +f(); +
[PATCH] D36580: [OpenCL] Support variable memory scope in atomic builtins
yaxunl marked 6 inline comments as done. yaxunl added inline comments. Comment at: lib/CodeGen/CGAtomic.cpp:678 + auto &Builder = CGF.Builder; + auto Scopes = getAllLanguageSyncScopes(); + llvm::DenseMap BB; t-tye wrote: > yaxunl wrote: > > t-tye wrote: > > > Should only the scopes that apply to the language be returned otherwise > > > will be generating code for invalid (possibly duplicate ABI) values? > > getAllLanguageSyncScopes() only returns scope values for current language. > > I will rename it to getRuntimeSyncScopeValuesForCurrentLanguage() to avoid > > confusing. > Curretly getAllLanguageSyncScopes does not take a LangOpt so not sure how it > knows what the language is, and did not see it checking that the language is > OpenCL internally. For non-OpenCL languages do they still have to support > system scope? For now I just assume all languages use OpenCL memory scope ABI. If a language has its own memory scope ABI it can be added later. Comment at: lib/Frontend/InitPreprocessor.cpp:582 // The values should match clang SyncScope enum. - assert(static_cast(SyncScope::OpenCLWorkGroup) == 1 && - static_cast(SyncScope::OpenCLDevice) == 2 && - static_cast(SyncScope::OpenCLAllSVMDevices) == 3 && - static_cast(SyncScope::OpenCLSubGroup) == 4); + assert(static_cast(OpenCLMemoryScope::WorkGroup) == 1 && + static_cast(OpenCLMemoryScope::Device) == 2 && t-tye wrote: > Could this be static_assert? Will do. https://reviews.llvm.org/D36580 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D36580: [OpenCL] Support variable memory scope in atomic builtins
yaxunl updated this revision to Diff 110904. yaxunl marked 2 inline comments as done. yaxunl added a comment. Refactor to introduce classes AtomicScopeABI and AtomicScopeOpenCLABI for easy extension to other languages. https://reviews.llvm.org/D36580 Files: include/clang/AST/ASTContext.h include/clang/Basic/DiagnosticSemaKinds.td include/clang/Basic/SyncScope.h lib/AST/ASTContext.cpp lib/CodeGen/CGAtomic.cpp lib/Frontend/InitPreprocessor.cpp lib/Sema/SemaChecking.cpp test/CodeGenOpenCL/atomic-ops-libcall.cl test/CodeGenOpenCL/atomic-ops.cl test/SemaOpenCL/atomic-ops.cl Index: test/SemaOpenCL/atomic-ops.cl === --- test/SemaOpenCL/atomic-ops.cl +++ test/SemaOpenCL/atomic-ops.cl @@ -14,7 +14,6 @@ int8 i64; atomic_int gn; - void f(atomic_int *i, const atomic_int *ci, atomic_intptr_t *p, atomic_float *d, int *I, const int *CI, @@ -81,6 +80,13 @@ } void memory_checks(atomic_int *Ap, int *p, int val) { + // non-integer memory order argument is casted to integer type. + (void)__opencl_atomic_load(Ap, 1.0f, memory_scope_work_group); + float forder; + (void)__opencl_atomic_load(Ap, forder, memory_scope_work_group); + struct S s; + (void)__opencl_atomic_load(Ap, s, memory_scope_work_group); // expected-error {{passing 'struct S' to parameter of incompatible type 'int'}} + (void)__opencl_atomic_load(Ap, memory_order_relaxed, memory_scope_work_group); (void)__opencl_atomic_load(Ap, memory_order_acquire, memory_scope_work_group); (void)__opencl_atomic_load(Ap, memory_order_consume, memory_scope_work_group); // expected-error {{use of undeclared identifier 'memory_order_consume'}} @@ -151,8 +157,15 @@ (void)__opencl_atomic_load(Ap, memory_order_relaxed, memory_scope_device); (void)__opencl_atomic_load(Ap, memory_order_relaxed, memory_scope_all_svm_devices); (void)__opencl_atomic_load(Ap, memory_order_relaxed, memory_scope_sub_group); - (void)__opencl_atomic_load(Ap, memory_order_relaxed, scope); // expected-error{{non-constant synchronization scope argument to atomic operation is not supported}} + (void)__opencl_atomic_load(Ap, memory_order_relaxed, scope); (void)__opencl_atomic_load(Ap, memory_order_relaxed, 10);//expected-error{{synchronization scope argument to atomic operation is invalid}} + + // non-integer memory scope is casted to integer type. + float fscope; + (void)__opencl_atomic_load(Ap, memory_order_relaxed, 1.0f); + (void)__opencl_atomic_load(Ap, memory_order_relaxed, fscope); + struct S s; + (void)__opencl_atomic_load(Ap, memory_order_relaxed, s); //expected-error{{passing 'struct S' to parameter of incompatible type 'int'}} } void nullPointerWarning(atomic_int *Ap, int *p, int val) { Index: test/CodeGenOpenCL/atomic-ops.cl === --- test/CodeGenOpenCL/atomic-ops.cl +++ test/CodeGenOpenCL/atomic-ops.cl @@ -52,6 +52,81 @@ return __opencl_atomic_compare_exchange_strong(i, &cmp, 1, memory_order_acquire, memory_order_acquire, memory_scope_work_group); } +void fi5(atomic_int *i, int scope) { + // CHECK-LABEL: @fi5 + // CHECK: switch i32 %{{.*}}, label %opencl_allsvmdevices [ + // CHECK-NEXT: i32 1, label %opencl_workgroup + // CHECK-NEXT: i32 2, label %opencl_device + // CHECK-NEXT: i32 4, label %opencl_subgroup + // CHECK-NEXT: ] + // CHECK: opencl_workgroup: + // CHECK: load atomic i32, i32 addrspace(4)* %{{.*}} syncscope("workgroup") seq_cst + // CHECK: br label %atomic.scope.continue + // CHECK: opencl_device: + // CHECK: load atomic i32, i32 addrspace(4)* %{{.*}} syncscope("agent") seq_cst + // CHECK: br label %atomic.scope.continue + // CHECK: opencl_allsvmdevices: + // CHECK: load atomic i32, i32 addrspace(4)* %{{.*}} seq_cst, align 4 + // CHECK: br label %atomic.scope.continue + // CHECK: opencl_subgroup: + // CHECK: %5 = load atomic i32, i32 addrspace(4)* %0 syncscope("subgroup") seq_cst, align 4 + // CHECK: br label %atomic.scope.continue + // CHECK: atomic.scope.continue: + int x = __opencl_atomic_load(i, memory_order_seq_cst, scope); +} + +void fi6(atomic_int *i, int order, int scope) { + // CHECK-LABEL: @fi6 + // CHECK: switch i32 %{{.*}}, label %monotonic [ + // CHECK-NEXT: i32 1, label %acquire + // CHECK-NEXT: i32 2, label %acquire + // CHECK-NEXT: i32 5, label %seqcst + // CHECK-NEXT: ] + // CHECK: monotonic: + // CHECK: switch i32 %{{.*}}, label %[[MON_ALL:.*]] [ + // CHECK-NEXT: i32 1, label %[[MON_WG:.*]] + // CHECK-NEXT: i32 2, label %[[MON_DEV:.*]] + // CHECK-NEXT: i32 4, label %[[MON_SUB:.*]] + // CHECK-NEXT: ] + // CHECK: acquire: + // CHECK: switch i32 %{{.*}}, label %[[ACQ_ALL:.*]] [ + // CHECK-NEXT: i32 1, label %[[ACQ_WG:.*]] + // CHECK-NEXT: i32 2, label %[[ACQ_DEV:.*]] + // CHECK-NEXT: i32 4, label %[[ACQ_SUB:.*]] + // CHECK-NEXT: ] + // CHECK: seqcst: + // CHECK: switch i32 %2, label %[[SEQ_ALL:.*]] [ + // CHECK-NEXT:
[PATCH] D36580: [OpenCL] Support variable memory scope in atomic builtins
t-tye accepted this revision. t-tye added a comment. LGTM https://reviews.llvm.org/D36580 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D36057: Use class to pass information about executable name
sepavloff updated this revision to Diff 110906. sepavloff added a comment. Herald added a subscriber: mgorny. Updated patch - The class representing info about clang executable name now keeps driver mode component as well, - Added unit tests. https://reviews.llvm.org/D36057 Files: include/clang/Driver/Driver.h include/clang/Driver/ToolChain.h lib/Driver/Driver.cpp lib/Driver/ToolChain.cpp lib/Tooling/Tooling.cpp tools/driver/driver.cpp unittests/Driver/CMakeLists.txt unittests/Driver/ToolChainTest.cpp Index: unittests/Driver/ToolChainTest.cpp === --- unittests/Driver/ToolChainTest.cpp +++ unittests/Driver/ToolChainTest.cpp @@ -18,6 +18,8 @@ #include "clang/Basic/VirtualFileSystem.h" #include "clang/Driver/Compilation.h" #include "clang/Driver/Driver.h" +#include "llvm/Support/TargetRegistry.h" +#include "llvm/Support/TargetSelect.h" #include "llvm/Support/raw_ostream.h" #include "gtest/gtest.h" using namespace clang; @@ -164,4 +166,98 @@ EXPECT_TRUE(C->containsError()); } +TEST(ToolChainTest, ParsedClangName) { + ParsedClangName Empty; + EXPECT_TRUE(Empty.TargetPrefix.empty()); + EXPECT_TRUE(Empty.ModeSuffix.empty()); + EXPECT_TRUE(Empty.DriverMode == nullptr); + EXPECT_FALSE(Empty.TargetIsValid); + + ParsedClangName DriverOnly("clang", nullptr); + EXPECT_TRUE(DriverOnly.TargetPrefix.empty()); + EXPECT_TRUE(DriverOnly.ModeSuffix == "clang"); + EXPECT_TRUE(DriverOnly.DriverMode == nullptr); + EXPECT_FALSE(DriverOnly.TargetIsValid); + + ParsedClangName DriverOnly2("clang++", "--driver-mode=g++"); + EXPECT_TRUE(DriverOnly2.TargetPrefix.empty()); + EXPECT_TRUE(DriverOnly2.ModeSuffix == "clang++"); + EXPECT_STREQ(DriverOnly2.DriverMode, "--driver-mode=g++"); + EXPECT_FALSE(DriverOnly2.TargetIsValid); + + ParsedClangName TargetAndMode("i386", "clang-g++", "--driver-mode=g++", true); + EXPECT_TRUE(TargetAndMode.TargetPrefix == "i386"); + EXPECT_TRUE(TargetAndMode.ModeSuffix == "clang-g++"); + EXPECT_STREQ(TargetAndMode.DriverMode, "--driver-mode=g++"); + EXPECT_TRUE(TargetAndMode.TargetIsValid); +} + +TEST(ToolChainTest, GetTargetAndMode) { + llvm::InitializeAllTargets(); + std::string IgnoredError; + if (!llvm::TargetRegistry::lookupTarget("x86_64", IgnoredError)) +return; + + ParsedClangName Res = ToolChain::getTargetAndModeFromProgramName("clang"); + EXPECT_TRUE(Res.TargetPrefix.empty()); + EXPECT_TRUE(Res.ModeSuffix == "clang"); + EXPECT_TRUE(Res.DriverMode == nullptr); + EXPECT_FALSE(Res.TargetIsValid); + + Res = ToolChain::getTargetAndModeFromProgramName("clang++"); + EXPECT_TRUE(Res.TargetPrefix.empty()); + EXPECT_TRUE(Res.ModeSuffix == "clang++"); + EXPECT_STREQ(Res.DriverMode, "--driver-mode=g++"); + EXPECT_FALSE(Res.TargetIsValid); + + Res = ToolChain::getTargetAndModeFromProgramName("clang++6.0"); + EXPECT_TRUE(Res.TargetPrefix.empty()); + EXPECT_TRUE(Res.ModeSuffix == "clang++"); + EXPECT_STREQ(Res.DriverMode, "--driver-mode=g++"); + EXPECT_FALSE(Res.TargetIsValid); + + Res = ToolChain::getTargetAndModeFromProgramName("clang++-release"); + EXPECT_TRUE(Res.TargetPrefix.empty()); + EXPECT_TRUE(Res.ModeSuffix == "clang++"); + EXPECT_STREQ(Res.DriverMode, "--driver-mode=g++"); + EXPECT_FALSE(Res.TargetIsValid); + + Res = ToolChain::getTargetAndModeFromProgramName("x86_64-clang++"); + EXPECT_TRUE(Res.TargetPrefix == "x86_64"); + EXPECT_TRUE(Res.ModeSuffix == "clang++"); + EXPECT_STREQ(Res.DriverMode, "--driver-mode=g++"); + EXPECT_TRUE(Res.TargetIsValid); + + Res = ToolChain::getTargetAndModeFromProgramName( + "x86_64-linux-gnu-clang-c++"); + EXPECT_TRUE(Res.TargetPrefix == "x86_64-linux-gnu"); + EXPECT_TRUE(Res.ModeSuffix == "clang-c++"); + EXPECT_STREQ(Res.DriverMode, "--driver-mode=g++"); + EXPECT_TRUE(Res.TargetIsValid); + + Res = ToolChain::getTargetAndModeFromProgramName( + "x86_64-linux-gnu-clang-c++-tot"); + EXPECT_TRUE(Res.TargetPrefix == "x86_64-linux-gnu"); + EXPECT_TRUE(Res.ModeSuffix == "clang-c++"); + EXPECT_STREQ(Res.DriverMode, "--driver-mode=g++"); + EXPECT_TRUE(Res.TargetIsValid); + + Res = ToolChain::getTargetAndModeFromProgramName("qqq"); + EXPECT_TRUE(Res.TargetPrefix.empty()); + EXPECT_TRUE(Res.ModeSuffix.empty()); + EXPECT_TRUE(Res.DriverMode == nullptr); + EXPECT_FALSE(Res.TargetIsValid); + + Res = ToolChain::getTargetAndModeFromProgramName("x86_64-qqq"); + EXPECT_TRUE(Res.TargetPrefix.empty()); + EXPECT_TRUE(Res.ModeSuffix.empty()); + EXPECT_TRUE(Res.DriverMode == nullptr); + EXPECT_FALSE(Res.TargetIsValid); + + Res = ToolChain::getTargetAndModeFromProgramName("qqq-clang-cl"); + EXPECT_TRUE(Res.TargetPrefix == "qqq"); + EXPECT_TRUE(Res.ModeSuffix == "clang-cl"); + EXPECT_STREQ(Res.DriverMode, "--driver-mode=cl"); + EXPECT_FALSE(Res.TargetIsValid); +} } // end anonymous namespace. Index: unittests/Driver/CMakeLists.txt === --- unittests
[PATCH] D24933: Enable configuration files in clang
sepavloff updated this revision to Diff 110909. sepavloff edited the summary of this revision. sepavloff added a comment. Updated patch - Some functionality, not related to config files directly, is move to separate changes - Cleanup of tests. This change does not implement using construct @file to apply config file yet. https://reviews.llvm.org/D24933 Files: docs/UsersManual.rst include/clang/Basic/DiagnosticDriverKinds.td include/clang/Config/config.h.cmake include/clang/Driver/Driver.h include/clang/Driver/Options.td include/clang/Driver/ToolChain.h lib/Driver/Driver.cpp lib/Driver/ToolChain.cpp lib/Tooling/Tooling.cpp test/Driver/Inputs/config-1.cfg test/Driver/Inputs/config-2.cfg test/Driver/Inputs/config-2a.cfg test/Driver/Inputs/config-3.cfg test/Driver/Inputs/config-4.cfg test/Driver/Inputs/config-5.cfg test/Driver/Inputs/config/config-4.cfg test/Driver/config-file-errs.c test/Driver/config-file.c test/Driver/config-file.cpp tools/driver/driver.cpp unittests/Driver/CMakeLists.txt unittests/Driver/ToolChainTest.cpp Index: unittests/Driver/ToolChainTest.cpp === --- unittests/Driver/ToolChainTest.cpp +++ unittests/Driver/ToolChainTest.cpp @@ -18,6 +18,8 @@ #include "clang/Basic/VirtualFileSystem.h" #include "clang/Driver/Compilation.h" #include "clang/Driver/Driver.h" +#include "llvm/Support/TargetRegistry.h" +#include "llvm/Support/TargetSelect.h" #include "llvm/Support/raw_ostream.h" #include "gtest/gtest.h" using namespace clang; @@ -164,4 +166,98 @@ EXPECT_TRUE(C->containsError()); } +TEST(ToolChainTest, ParsedClangName) { + ParsedClangName Empty; + EXPECT_TRUE(Empty.TargetPrefix.empty()); + EXPECT_TRUE(Empty.ModeSuffix.empty()); + EXPECT_TRUE(Empty.DriverMode == nullptr); + EXPECT_FALSE(Empty.TargetIsValid); + + ParsedClangName DriverOnly("clang", nullptr); + EXPECT_TRUE(DriverOnly.TargetPrefix.empty()); + EXPECT_TRUE(DriverOnly.ModeSuffix == "clang"); + EXPECT_TRUE(DriverOnly.DriverMode == nullptr); + EXPECT_FALSE(DriverOnly.TargetIsValid); + + ParsedClangName DriverOnly2("clang++", "--driver-mode=g++"); + EXPECT_TRUE(DriverOnly2.TargetPrefix.empty()); + EXPECT_TRUE(DriverOnly2.ModeSuffix == "clang++"); + EXPECT_STREQ(DriverOnly2.DriverMode, "--driver-mode=g++"); + EXPECT_FALSE(DriverOnly2.TargetIsValid); + + ParsedClangName TargetAndMode("i386", "clang-g++", "--driver-mode=g++", true); + EXPECT_TRUE(TargetAndMode.TargetPrefix == "i386"); + EXPECT_TRUE(TargetAndMode.ModeSuffix == "clang-g++"); + EXPECT_STREQ(TargetAndMode.DriverMode, "--driver-mode=g++"); + EXPECT_TRUE(TargetAndMode.TargetIsValid); +} + +TEST(ToolChainTest, GetTargetAndMode) { + llvm::InitializeAllTargets(); + std::string IgnoredError; + if (!llvm::TargetRegistry::lookupTarget("x86_64", IgnoredError)) +return; + + ParsedClangName Res = ToolChain::getTargetAndModeFromProgramName("clang"); + EXPECT_TRUE(Res.TargetPrefix.empty()); + EXPECT_TRUE(Res.ModeSuffix == "clang"); + EXPECT_TRUE(Res.DriverMode == nullptr); + EXPECT_FALSE(Res.TargetIsValid); + + Res = ToolChain::getTargetAndModeFromProgramName("clang++"); + EXPECT_TRUE(Res.TargetPrefix.empty()); + EXPECT_TRUE(Res.ModeSuffix == "clang++"); + EXPECT_STREQ(Res.DriverMode, "--driver-mode=g++"); + EXPECT_FALSE(Res.TargetIsValid); + + Res = ToolChain::getTargetAndModeFromProgramName("clang++6.0"); + EXPECT_TRUE(Res.TargetPrefix.empty()); + EXPECT_TRUE(Res.ModeSuffix == "clang++"); + EXPECT_STREQ(Res.DriverMode, "--driver-mode=g++"); + EXPECT_FALSE(Res.TargetIsValid); + + Res = ToolChain::getTargetAndModeFromProgramName("clang++-release"); + EXPECT_TRUE(Res.TargetPrefix.empty()); + EXPECT_TRUE(Res.ModeSuffix == "clang++"); + EXPECT_STREQ(Res.DriverMode, "--driver-mode=g++"); + EXPECT_FALSE(Res.TargetIsValid); + + Res = ToolChain::getTargetAndModeFromProgramName("x86_64-clang++"); + EXPECT_TRUE(Res.TargetPrefix == "x86_64"); + EXPECT_TRUE(Res.ModeSuffix == "clang++"); + EXPECT_STREQ(Res.DriverMode, "--driver-mode=g++"); + EXPECT_TRUE(Res.TargetIsValid); + + Res = ToolChain::getTargetAndModeFromProgramName( + "x86_64-linux-gnu-clang-c++"); + EXPECT_TRUE(Res.TargetPrefix == "x86_64-linux-gnu"); + EXPECT_TRUE(Res.ModeSuffix == "clang-c++"); + EXPECT_STREQ(Res.DriverMode, "--driver-mode=g++"); + EXPECT_TRUE(Res.TargetIsValid); + + Res = ToolChain::getTargetAndModeFromProgramName( + "x86_64-linux-gnu-clang-c++-tot"); + EXPECT_TRUE(Res.TargetPrefix == "x86_64-linux-gnu"); + EXPECT_TRUE(Res.ModeSuffix == "clang-c++"); + EXPECT_STREQ(Res.DriverMode, "--driver-mode=g++"); + EXPECT_TRUE(Res.TargetIsValid); + + Res = ToolChain::getTargetAndModeFromProgramName("qqq"); + EXPECT_TRUE(Res.TargetPrefix.empty()); + EXPECT_TRUE(Res.ModeSuffix.empty()); + EXPECT_TRUE(Res.DriverMode == nullptr); + EXPECT_FALSE(Res.TargetIsValid); + + Res = ToolChain::getTargetAndModeFromProgramName("x86_64-qqq"); + E