r375466 - [Implicit Modules] Add -cc1 option -fmodules-strict-context-hash which includes search paths and diagnostics.
Author: mspencer Date: Mon Oct 21 15:51:13 2019 New Revision: 375466 URL: http://llvm.org/viewvc/llvm-project?rev=375466=rev Log: [Implicit Modules] Add -cc1 option -fmodules-strict-context-hash which includes search paths and diagnostics. This is a recommit of r375322 and r375327 with a fix for the Windows test breakage. Added: cfe/trunk/test/Modules/context-hash.c Modified: cfe/trunk/docs/Modules.rst cfe/trunk/include/clang/Driver/CC1Options.td cfe/trunk/include/clang/Lex/HeaderSearchOptions.h cfe/trunk/lib/Frontend/CompilerInvocation.cpp Modified: cfe/trunk/docs/Modules.rst URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/Modules.rst?rev=375466=375465=375466=diff == --- cfe/trunk/docs/Modules.rst (original) +++ cfe/trunk/docs/Modules.rst Mon Oct 21 15:51:13 2019 @@ -225,6 +225,16 @@ Command-line parameters ``-fprebuilt-module-path=`` Specify the path to the prebuilt modules. If specified, we will look for modules in this directory for a given top-level module name. We don't need a module map for loading prebuilt modules in this directory and the compiler will not try to rebuild these modules. This can be specified multiple times. +-cc1 Options + + +``-fmodules-strict-context-hash`` + Enables hashing of all compiler options that could impact the semantics of a + module in an implicit build. This includes things such as header search paths + and diagnostics. Using this option may lead to an excessive number of modules + being built if the command line arguments are not homogeneous across your + build. + Module Semantics Modified: cfe/trunk/include/clang/Driver/CC1Options.td URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/CC1Options.td?rev=375466=375465=375466=diff == --- cfe/trunk/include/clang/Driver/CC1Options.td (original) +++ cfe/trunk/include/clang/Driver/CC1Options.td Mon Oct 21 15:51:13 2019 @@ -815,6 +815,9 @@ def fdisable_module_hash : Flag<["-"], " HelpText<"Disable the module hash">; def fmodules_hash_content : Flag<["-"], "fmodules-hash-content">, HelpText<"Enable hashing the content of a module file">; +def fmodules_strict_context_hash : Flag<["-"], "fmodules-strict-context-hash">, + HelpText<"Enable hashing of all compiler options that could impact the " + "semantics of a module in an implicit build">; def c_isystem : JoinedOrSeparate<["-"], "c-isystem">, MetaVarName<"">, HelpText<"Add directory to the C SYSTEM include search path">; def objc_isystem : JoinedOrSeparate<["-"], "objc-isystem">, Modified: cfe/trunk/include/clang/Lex/HeaderSearchOptions.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Lex/HeaderSearchOptions.h?rev=375466=375465=375466=diff == --- cfe/trunk/include/clang/Lex/HeaderSearchOptions.h (original) +++ cfe/trunk/include/clang/Lex/HeaderSearchOptions.h Mon Oct 21 15:51:13 2019 @@ -11,6 +11,7 @@ #include "clang/Basic/LLVM.h" #include "llvm/ADT/CachedHashString.h" +#include "llvm/ADT/Hashing.h" #include "llvm/ADT/SetVector.h" #include "llvm/ADT/StringRef.h" #include @@ -206,6 +207,13 @@ public: unsigned ModulesHashContent : 1; + /// Whether we should include all things that could impact the module in the + /// hash. + /// + /// This includes things like the full header search path, and enabled + /// diagnostics. + unsigned ModulesStrictContextHash : 1; + HeaderSearchOptions(StringRef _Sysroot = "/") : Sysroot(_Sysroot), ModuleFormat("raw"), DisableModuleHash(false), ImplicitModuleMaps(false), ModuleMapFileHomeIsCwd(false), @@ -214,7 +222,8 @@ public: ModulesValidateOncePerBuildSession(false), ModulesValidateSystemHeaders(false), ValidateASTInputFilesContent(false), UseDebugInfo(false), -ModulesValidateDiagnosticOptions(true), ModulesHashContent(false) {} +ModulesValidateDiagnosticOptions(true), ModulesHashContent(false), +ModulesStrictContextHash(false) {} /// AddPath - Add the \p Path path to the specified \p Group list. void AddPath(StringRef Path, frontend::IncludeDirGroup Group, @@ -238,6 +247,15 @@ public: } }; +inline llvm::hash_code hash_value(const HeaderSearchOptions::Entry ) { + return llvm::hash_combine(E.Path, E.Group, E.IsFramework, E.IgnoreSysRoot); +} + +inline llvm::hash_code +hash_value(const HeaderSearchOptions::SystemHeaderPrefix ) { + return llvm::hash_combine(SHP.Prefix, SHP.IsSystemHeader); +} + } // namespace clang #endif // LLVM_CLANG_LEX_HEADERSEARCHOPTIONS_H Modified: cfe/trunk/lib/Frontend/CompilerInvocation.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/CompilerInvocation.cpp?rev=375466=375465=375466=diff
r375338 - Revert "[Implicit Modules] Add -cc1 option -fmodules-strict-context-hash which includes search paths and diagnostics." and "[Docs] Fix header level."
Author: mspencer Date: Sat Oct 19 02:45:28 2019 New Revision: 375338 URL: http://llvm.org/viewvc/llvm-project?rev=375338=rev Log: Revert "[Implicit Modules] Add -cc1 option -fmodules-strict-context-hash which includes search paths and diagnostics." and "[Docs] Fix header level." The test doesn't work on Windows. I'll fix it and recommit later. Removed: cfe/trunk/test/Modules/context-hash.c Modified: cfe/trunk/docs/Modules.rst cfe/trunk/include/clang/Driver/CC1Options.td cfe/trunk/include/clang/Lex/HeaderSearchOptions.h cfe/trunk/lib/Frontend/CompilerInvocation.cpp Modified: cfe/trunk/docs/Modules.rst URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/Modules.rst?rev=375338=375337=375338=diff == --- cfe/trunk/docs/Modules.rst (original) +++ cfe/trunk/docs/Modules.rst Sat Oct 19 02:45:28 2019 @@ -225,16 +225,6 @@ Command-line parameters ``-fprebuilt-module-path=`` Specify the path to the prebuilt modules. If specified, we will look for modules in this directory for a given top-level module name. We don't need a module map for loading prebuilt modules in this directory and the compiler will not try to rebuild these modules. This can be specified multiple times. --cc1 Options - - -``-fmodules-strict-context-hash`` - Enables hashing of all compiler options that could impact the semantics of a - module in an implicit build. This includes things such as header search paths - and diagnostics. Using this option may lead to an excessive number of modules - being built if the command line arguments are not homogeneous across your - build. - Module Semantics Modified: cfe/trunk/include/clang/Driver/CC1Options.td URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/CC1Options.td?rev=375338=375337=375338=diff == --- cfe/trunk/include/clang/Driver/CC1Options.td (original) +++ cfe/trunk/include/clang/Driver/CC1Options.td Sat Oct 19 02:45:28 2019 @@ -815,9 +815,6 @@ def fdisable_module_hash : Flag<["-"], " HelpText<"Disable the module hash">; def fmodules_hash_content : Flag<["-"], "fmodules-hash-content">, HelpText<"Enable hashing the content of a module file">; -def fmodules_strict_context_hash : Flag<["-"], "fmodules-strict-context-hash">, - HelpText<"Enable hashing of all compiler options that could impact the " - "semantics of a module in an implicit build">; def c_isystem : JoinedOrSeparate<["-"], "c-isystem">, MetaVarName<"">, HelpText<"Add directory to the C SYSTEM include search path">; def objc_isystem : JoinedOrSeparate<["-"], "objc-isystem">, Modified: cfe/trunk/include/clang/Lex/HeaderSearchOptions.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Lex/HeaderSearchOptions.h?rev=375338=375337=375338=diff == --- cfe/trunk/include/clang/Lex/HeaderSearchOptions.h (original) +++ cfe/trunk/include/clang/Lex/HeaderSearchOptions.h Sat Oct 19 02:45:28 2019 @@ -11,7 +11,6 @@ #include "clang/Basic/LLVM.h" #include "llvm/ADT/CachedHashString.h" -#include "llvm/ADT/Hashing.h" #include "llvm/ADT/SetVector.h" #include "llvm/ADT/StringRef.h" #include @@ -207,13 +206,6 @@ public: unsigned ModulesHashContent : 1; - /// Whether we should include all things that could impact the module in the - /// hash. - /// - /// This includes things like the full header search path, and enabled - /// diagnostics. - unsigned ModulesStrictContextHash : 1; - HeaderSearchOptions(StringRef _Sysroot = "/") : Sysroot(_Sysroot), ModuleFormat("raw"), DisableModuleHash(false), ImplicitModuleMaps(false), ModuleMapFileHomeIsCwd(false), @@ -222,8 +214,7 @@ public: ModulesValidateOncePerBuildSession(false), ModulesValidateSystemHeaders(false), ValidateASTInputFilesContent(false), UseDebugInfo(false), -ModulesValidateDiagnosticOptions(true), ModulesHashContent(false), -ModulesStrictContextHash(false) {} +ModulesValidateDiagnosticOptions(true), ModulesHashContent(false) {} /// AddPath - Add the \p Path path to the specified \p Group list. void AddPath(StringRef Path, frontend::IncludeDirGroup Group, @@ -247,15 +238,6 @@ public: } }; -inline llvm::hash_code hash_value(const HeaderSearchOptions::Entry ) { - return llvm::hash_combine(E.Path, E.Group, E.IsFramework, E.IgnoreSysRoot); -} - -inline llvm::hash_code -hash_value(const HeaderSearchOptions::SystemHeaderPrefix ) { - return llvm::hash_combine(SHP.Prefix, SHP.IsSystemHeader); -} - } // namespace clang #endif // LLVM_CLANG_LEX_HEADERSEARCHOPTIONS_H Modified: cfe/trunk/lib/Frontend/CompilerInvocation.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/CompilerInvocation.cpp?rev=375338=375337=375338=diff
r375327 - [Docs] Fix header level.
Author: mspencer Date: Fri Oct 18 18:48:57 2019 New Revision: 375327 URL: http://llvm.org/viewvc/llvm-project?rev=375327=rev Log: [Docs] Fix header level. Modified: cfe/trunk/docs/Modules.rst Modified: cfe/trunk/docs/Modules.rst URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/Modules.rst?rev=375327=375326=375327=diff == --- cfe/trunk/docs/Modules.rst (original) +++ cfe/trunk/docs/Modules.rst Fri Oct 18 18:48:57 2019 @@ -226,7 +226,7 @@ Command-line parameters Specify the path to the prebuilt modules. If specified, we will look for modules in this directory for a given top-level module name. We don't need a module map for loading prebuilt modules in this directory and the compiler will not try to rebuild these modules. This can be specified multiple times. -cc1 Options - + ``-fmodules-strict-context-hash`` Enables hashing of all compiler options that could impact the semantics of a ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r375322 - [Implicit Modules] Add -cc1 option -fmodules-strict-context-hash which includes search paths and diagnostics.
Author: mspencer Date: Fri Oct 18 18:36:37 2019 New Revision: 375322 URL: http://llvm.org/viewvc/llvm-project?rev=375322=rev Log: [Implicit Modules] Add -cc1 option -fmodules-strict-context-hash which includes search paths and diagnostics. Differential Revision: https://reviews.llvm.org/D68528 Added: cfe/trunk/test/Modules/context-hash.c Modified: cfe/trunk/docs/Modules.rst cfe/trunk/include/clang/Driver/CC1Options.td cfe/trunk/include/clang/Lex/HeaderSearchOptions.h cfe/trunk/lib/Frontend/CompilerInvocation.cpp Modified: cfe/trunk/docs/Modules.rst URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/Modules.rst?rev=375322=375321=375322=diff == --- cfe/trunk/docs/Modules.rst (original) +++ cfe/trunk/docs/Modules.rst Fri Oct 18 18:36:37 2019 @@ -225,6 +225,16 @@ Command-line parameters ``-fprebuilt-module-path=`` Specify the path to the prebuilt modules. If specified, we will look for modules in this directory for a given top-level module name. We don't need a module map for loading prebuilt modules in this directory and the compiler will not try to rebuild these modules. This can be specified multiple times. +-cc1 Options + + +``-fmodules-strict-context-hash`` + Enables hashing of all compiler options that could impact the semantics of a + module in an implicit build. This includes things such as header search paths + and diagnostics. Using this option may lead to an excessive number of modules + being built if the command line arguments are not homogeneous across your + build. + Module Semantics Modified: cfe/trunk/include/clang/Driver/CC1Options.td URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/CC1Options.td?rev=375322=375321=375322=diff == --- cfe/trunk/include/clang/Driver/CC1Options.td (original) +++ cfe/trunk/include/clang/Driver/CC1Options.td Fri Oct 18 18:36:37 2019 @@ -815,6 +815,9 @@ def fdisable_module_hash : Flag<["-"], " HelpText<"Disable the module hash">; def fmodules_hash_content : Flag<["-"], "fmodules-hash-content">, HelpText<"Enable hashing the content of a module file">; +def fmodules_strict_context_hash : Flag<["-"], "fmodules-strict-context-hash">, + HelpText<"Enable hashing of all compiler options that could impact the " + "semantics of a module in an implicit build">; def c_isystem : JoinedOrSeparate<["-"], "c-isystem">, MetaVarName<"">, HelpText<"Add directory to the C SYSTEM include search path">; def objc_isystem : JoinedOrSeparate<["-"], "objc-isystem">, Modified: cfe/trunk/include/clang/Lex/HeaderSearchOptions.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Lex/HeaderSearchOptions.h?rev=375322=375321=375322=diff == --- cfe/trunk/include/clang/Lex/HeaderSearchOptions.h (original) +++ cfe/trunk/include/clang/Lex/HeaderSearchOptions.h Fri Oct 18 18:36:37 2019 @@ -11,6 +11,7 @@ #include "clang/Basic/LLVM.h" #include "llvm/ADT/CachedHashString.h" +#include "llvm/ADT/Hashing.h" #include "llvm/ADT/SetVector.h" #include "llvm/ADT/StringRef.h" #include @@ -206,6 +207,13 @@ public: unsigned ModulesHashContent : 1; + /// Whether we should include all things that could impact the module in the + /// hash. + /// + /// This includes things like the full header search path, and enabled + /// diagnostics. + unsigned ModulesStrictContextHash : 1; + HeaderSearchOptions(StringRef _Sysroot = "/") : Sysroot(_Sysroot), ModuleFormat("raw"), DisableModuleHash(false), ImplicitModuleMaps(false), ModuleMapFileHomeIsCwd(false), @@ -214,7 +222,8 @@ public: ModulesValidateOncePerBuildSession(false), ModulesValidateSystemHeaders(false), ValidateASTInputFilesContent(false), UseDebugInfo(false), -ModulesValidateDiagnosticOptions(true), ModulesHashContent(false) {} +ModulesValidateDiagnosticOptions(true), ModulesHashContent(false), +ModulesStrictContextHash(false) {} /// AddPath - Add the \p Path path to the specified \p Group list. void AddPath(StringRef Path, frontend::IncludeDirGroup Group, @@ -238,6 +247,15 @@ public: } }; +inline llvm::hash_code hash_value(const HeaderSearchOptions::Entry ) { + return llvm::hash_combine(E.Path, E.Group, E.IsFramework, E.IgnoreSysRoot); +} + +inline llvm::hash_code +hash_value(const HeaderSearchOptions::SystemHeaderPrefix ) { + return llvm::hash_combine(SHP.Prefix, SHP.IsSystemHeader); +} + } // namespace clang #endif // LLVM_CLANG_LEX_HEADERSEARCHOPTIONS_H Modified: cfe/trunk/lib/Frontend/CompilerInvocation.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/CompilerInvocation.cpp?rev=375322=375321=375322=diff
r374439 - [ScanDeps] clang-format, 80 cols.
Author: mspencer Date: Thu Oct 10 13:19:02 2019 New Revision: 374439 URL: http://llvm.org/viewvc/llvm-project?rev=374439=rev Log: [ScanDeps] clang-format, 80 cols. Modified: cfe/trunk/lib/Tooling/DependencyScanning/DependencyScanningFilesystem.cpp Modified: cfe/trunk/lib/Tooling/DependencyScanning/DependencyScanningFilesystem.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Tooling/DependencyScanning/DependencyScanningFilesystem.cpp?rev=374439=374438=374439=diff == --- cfe/trunk/lib/Tooling/DependencyScanning/DependencyScanningFilesystem.cpp (original) +++ cfe/trunk/lib/Tooling/DependencyScanning/DependencyScanningFilesystem.cpp Thu Oct 10 13:19:02 2019 @@ -123,8 +123,9 @@ DependencyScanningFilesystemSharedCache: } llvm::ErrorOr -DependencyScanningWorkerFilesystem::getOrCreateFileSystemEntry(const StringRef Filename) { - if (const CachedFileSystemEntry* Entry = getCachedEntry(Filename)) { +DependencyScanningWorkerFilesystem::getOrCreateFileSystemEntry( +const StringRef Filename) { + if (const CachedFileSystemEntry *Entry = getCachedEntry(Filename)) { return Entry; } @@ -164,7 +165,8 @@ llvm::ErrorOr DependencyScanningWorkerFilesystem::status(const Twine ) { SmallString<256> OwnedFilename; StringRef Filename = Path.toStringRef(OwnedFilename); - const llvm::ErrorOr Result = getOrCreateFileSystemEntry(Filename); + const llvm::ErrorOr Result = + getOrCreateFileSystemEntry(Filename); if (!Result) return Result.getError(); return (*Result)->getStatus(); @@ -224,7 +226,8 @@ DependencyScanningWorkerFilesystem::open SmallString<256> OwnedFilename; StringRef Filename = Path.toStringRef(OwnedFilename); - const llvm::ErrorOr Result = getOrCreateFileSystemEntry(Filename); + const llvm::ErrorOr Result = + getOrCreateFileSystemEntry(Filename); if (!Result) return Result.getError(); return createFile(Result.get(), PPSkipMappings); ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r368381 - [clang-scan-deps] Add minimizer support for C++20 modules.
Author: mspencer Date: Thu Aug 8 19:01:10 2019 New Revision: 368381 URL: http://llvm.org/viewvc/llvm-project?rev=368381=rev Log: [clang-scan-deps] Add minimizer support for C++20 modules. This only adds support to the minimizer, it doesn't actually capture the dependencies yet. Modified: cfe/trunk/include/clang/Lex/DependencyDirectivesSourceMinimizer.h cfe/trunk/lib/Lex/DependencyDirectivesSourceMinimizer.cpp cfe/trunk/unittests/Lex/DependencyDirectivesSourceMinimizerTest.cpp Modified: cfe/trunk/include/clang/Lex/DependencyDirectivesSourceMinimizer.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Lex/DependencyDirectivesSourceMinimizer.h?rev=368381=368380=368381=diff == --- cfe/trunk/include/clang/Lex/DependencyDirectivesSourceMinimizer.h (original) +++ cfe/trunk/include/clang/Lex/DependencyDirectivesSourceMinimizer.h Thu Aug 8 19:01:10 2019 @@ -47,6 +47,9 @@ enum TokenKind { pp_else, pp_endif, decl_at_import, + cxx_export_decl, + cxx_module_decl, + cxx_import_decl, pp_eof, }; Modified: cfe/trunk/lib/Lex/DependencyDirectivesSourceMinimizer.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/DependencyDirectivesSourceMinimizer.cpp?rev=368381=368380=368381=diff == --- cfe/trunk/lib/Lex/DependencyDirectivesSourceMinimizer.cpp (original) +++ cfe/trunk/lib/Lex/DependencyDirectivesSourceMinimizer.cpp Thu Aug 8 19:01:10 2019 @@ -59,6 +59,7 @@ private: LLVM_NODISCARD bool minimizeImpl(const char *First, const char *const End); LLVM_NODISCARD bool lexPPLine(const char *, const char *const End); LLVM_NODISCARD bool lexAt(const char *, const char *const End); + LLVM_NODISCARD bool lexModule(const char *, const char *const End); LLVM_NODISCARD bool lexDefine(const char *, const char *const End); LLVM_NODISCARD bool lexPragma(const char *, const char *const End); LLVM_NODISCARD bool lexEndif(const char *, const char *const End); @@ -576,6 +577,59 @@ bool Minimizer::lexAt(const char * return false; } +bool Minimizer::lexModule(const char *, const char *const End) { + IdInfo Id = lexIdentifier(First, End); + First = Id.Last; + bool Export = false; + if (Id.Name == "export") { +Export = true; +skipWhitespace(First, End); +if (!isIdentifierBody(*First)) { + skipLine(First, End); + return false; +} +Id = lexIdentifier(First, End); +First = Id.Last; + } + + if (Id.Name != "module" && Id.Name != "import") { +skipLine(First, End); +return false; + } + + skipWhitespace(First, End); + + // Ignore this as a module directive if the next character can't be part of + // an import. + + switch (*First) { + case ':': + case '<': + case '"': +break; + default: +if (!isIdentifierBody(*First)) { + skipLine(First, End); + return false; +} + } + + if (Export) { +makeToken(cxx_export_decl); +append("export "); + } + + if (Id.Name == "module") +makeToken(cxx_module_decl); + else +makeToken(cxx_import_decl); + append(Id.Name); + append(" "); + printToNewline(First, End); + append("\n"); + return false; +} + bool Minimizer::lexDefine(const char *, const char *const End) { makeToken(pp_define); append("#define "); @@ -677,6 +731,18 @@ bool Minimizer::lexDefault(TokenKind Kin return false; } +static bool isStartOfRelevantLine(char First) { + switch (First) { + case '#': + case '@': + case 'i': + case 'e': + case 'm': +return true; + } + return false; +} + bool Minimizer::lexPPLine(const char *, const char *const End) { assert(First != End); @@ -685,7 +751,7 @@ bool Minimizer::lexPPLine(const char * if (First == End) return false; - if (*First != '#' && *First != '@') { + if (!isStartOfRelevantLine(*First)) { skipLine(First, End); assert(First <= End); return false; @@ -695,6 +761,9 @@ bool Minimizer::lexPPLine(const char * if (*First == '@') return lexAt(First, End); + if (*First == 'i' || *First == 'e' || *First == 'm') +return lexModule(First, End); + // Handle preprocessing directives. ++First; // Skip over '#'. skipWhitespace(First, End); Modified: cfe/trunk/unittests/Lex/DependencyDirectivesSourceMinimizerTest.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Lex/DependencyDirectivesSourceMinimizerTest.cpp?rev=368381=368380=368381=diff == --- cfe/trunk/unittests/Lex/DependencyDirectivesSourceMinimizerTest.cpp (original) +++ cfe/trunk/unittests/Lex/DependencyDirectivesSourceMinimizerTest.cpp Thu Aug 8 19:01:10 2019 @@ -60,7 +60,9 @@ TEST(MinimizeSourceToDependencyDirective "#__include_macros \n" "#import \n"
r367479 - [clang][ARM] Fix msvc arm{64} builtins to use int on LP64 systems.
Author: mspencer Date: Wed Jul 31 13:42:28 2019 New Revision: 367479 URL: http://llvm.org/viewvc/llvm-project?rev=367479=rev Log: [clang][ARM] Fix msvc arm{64} builtins to use int on LP64 systems. The `InterlockedX_{acq,nf,rel}` functions deal with 32 bits which is long on MSVC, but int on most other systems. This also checks that `ReadStatusRegister` and `WriteStatusRegister` have the correct type on aarch64-darwin. Differential Revision: https://reviews.llvm.org/D64164 Modified: cfe/trunk/include/clang/Basic/BuiltinsAArch64.def cfe/trunk/include/clang/Basic/BuiltinsARM.def cfe/trunk/test/CodeGen/arm64-microsoft-status-reg.cpp cfe/trunk/test/CodeGen/ms-intrinsics-other.c Modified: cfe/trunk/include/clang/Basic/BuiltinsAArch64.def URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/BuiltinsAArch64.def?rev=367479=367478=367479=diff == --- cfe/trunk/include/clang/Basic/BuiltinsAArch64.def (original) +++ cfe/trunk/include/clang/Basic/BuiltinsAArch64.def Wed Jul 31 13:42:28 2019 @@ -102,7 +102,7 @@ TARGET_HEADER_BUILTIN(_BitScanReverse, " TARGET_HEADER_BUILTIN(_BitScanForward64, "UcUNi*ULLi", "nh", "intrin.h", ALL_MS_LANGUAGES, "") TARGET_HEADER_BUILTIN(_BitScanReverse64, "UcUNi*ULLi", "nh", "intrin.h", ALL_MS_LANGUAGES, "") -TARGET_HEADER_BUILTIN(_InterlockedAdd, "LiLiD*Li","nh", "intrin.h", ALL_MS_LANGUAGES, "") +TARGET_HEADER_BUILTIN(_InterlockedAdd, "NiNiD*Ni","nh", "intrin.h", ALL_MS_LANGUAGES, "") TARGET_HEADER_BUILTIN(_InterlockedAnd64, "LLiLLiD*LLi", "nh", "intrin.h", ALL_MS_LANGUAGES, "") TARGET_HEADER_BUILTIN(_InterlockedDecrement64, "LLiLLiD*","nh", "intrin.h", ALL_MS_LANGUAGES, "") TARGET_HEADER_BUILTIN(_InterlockedExchange64,"LLiLLiD*LLi", "nh", "intrin.h", ALL_MS_LANGUAGES, "") @@ -112,9 +112,9 @@ TARGET_HEADER_BUILTIN(_InterlockedIncrem TARGET_HEADER_BUILTIN(_InterlockedOr64, "LLiLLiD*LLi", "nh", "intrin.h", ALL_MS_LANGUAGES, "") TARGET_HEADER_BUILTIN(_InterlockedXor64, "LLiLLiD*LLi", "nh", "intrin.h", ALL_MS_LANGUAGES, "") -TARGET_HEADER_BUILTIN(_InterlockedExchangeAdd_acq, "LiLiD*Li", "nh", "intrin.h", ALL_MS_LANGUAGES, "") -TARGET_HEADER_BUILTIN(_InterlockedExchangeAdd_rel, "LiLiD*Li", "nh", "intrin.h", ALL_MS_LANGUAGES, "") -TARGET_HEADER_BUILTIN(_InterlockedExchangeAdd_nf, "LiLiD*Li", "nh", "intrin.h", ALL_MS_LANGUAGES, "") +TARGET_HEADER_BUILTIN(_InterlockedExchangeAdd_acq, "NiNiD*Ni", "nh", "intrin.h", ALL_MS_LANGUAGES, "") +TARGET_HEADER_BUILTIN(_InterlockedExchangeAdd_rel, "NiNiD*Ni", "nh", "intrin.h", ALL_MS_LANGUAGES, "") +TARGET_HEADER_BUILTIN(_InterlockedExchangeAdd_nf, "NiNiD*Ni", "nh", "intrin.h", ALL_MS_LANGUAGES, "") TARGET_HEADER_BUILTIN(_InterlockedExchangeAdd8_acq, "ccD*c", "nh", "intrin.h", ALL_MS_LANGUAGES, "") TARGET_HEADER_BUILTIN(_InterlockedExchangeAdd8_rel, "ccD*c", "nh", "intrin.h", ALL_MS_LANGUAGES, "") TARGET_HEADER_BUILTIN(_InterlockedExchangeAdd8_nf, "ccD*c", "nh", "intrin.h", ALL_MS_LANGUAGES, "") @@ -131,9 +131,9 @@ TARGET_HEADER_BUILTIN(_InterlockedExchan TARGET_HEADER_BUILTIN(_InterlockedExchange16_acq, "ssD*s", "nh", "intrin.h", ALL_MS_LANGUAGES, "") TARGET_HEADER_BUILTIN(_InterlockedExchange16_nf, "ssD*s", "nh", "intrin.h", ALL_MS_LANGUAGES, "") TARGET_HEADER_BUILTIN(_InterlockedExchange16_rel, "ssD*s", "nh", "intrin.h", ALL_MS_LANGUAGES, "") -TARGET_HEADER_BUILTIN(_InterlockedExchange_acq, "LiLiD*Li","nh", "intrin.h", ALL_MS_LANGUAGES, "") -TARGET_HEADER_BUILTIN(_InterlockedExchange_nf,"LiLiD*Li","nh", "intrin.h", ALL_MS_LANGUAGES, "") -TARGET_HEADER_BUILTIN(_InterlockedExchange_rel, "LiLiD*Li","nh", "intrin.h", ALL_MS_LANGUAGES, "") +TARGET_HEADER_BUILTIN(_InterlockedExchange_acq, "NiNiD*Ni","nh", "intrin.h", ALL_MS_LANGUAGES, "") +TARGET_HEADER_BUILTIN(_InterlockedExchange_nf,"NiNiD*Ni","nh", "intrin.h", ALL_MS_LANGUAGES, "") +TARGET_HEADER_BUILTIN(_InterlockedExchange_rel, "NiNiD*Ni","nh", "intrin.h", ALL_MS_LANGUAGES, "") TARGET_HEADER_BUILTIN(_InterlockedExchange64_acq, "LLiLLiD*LLi", "nh", "intrin.h", ALL_MS_LANGUAGES, "") TARGET_HEADER_BUILTIN(_InterlockedExchange64_nf, "LLiLLiD*LLi", "nh", "intrin.h", ALL_MS_LANGUAGES, "") TARGET_HEADER_BUILTIN(_InterlockedExchange64_rel, "LLiLLiD*LLi", "nh", "intrin.h", ALL_MS_LANGUAGES, "") @@ -144,9 +144,9 @@ TARGET_HEADER_BUILTIN(_InterlockedCompar TARGET_HEADER_BUILTIN(_InterlockedCompareExchange16_acq, "ssD*ss", "nh", "intrin.h", ALL_MS_LANGUAGES, "") TARGET_HEADER_BUILTIN(_InterlockedCompareExchange16_nf, "ssD*ss", "nh", "intrin.h", ALL_MS_LANGUAGES, "") TARGET_HEADER_BUILTIN(_InterlockedCompareExchange16_rel, "ssD*ss", "nh", "intrin.h", ALL_MS_LANGUAGES, "") -TARGET_HEADER_BUILTIN(_InterlockedCompareExchange_acq, "LiLiD*LiLi", "nh", "intrin.h", ALL_MS_LANGUAGES, "")
r361885 - [Driver] Fix -working-directory issues
Author: mspencer Date: Tue May 28 15:21:47 2019 New Revision: 361885 URL: http://llvm.org/viewvc/llvm-project?rev=361885=rev Log: [Driver] Fix -working-directory issues Currently the `-working-directory` option does not actually impact the working directory for all of the clang driver, it only impacts how files are looked up to make sure they exist. This means that that clang passes the wrong paths to -fdebug-compilation-dir and -coverage-notes-file. This patch fixes that by changing all the places in the driver where we convert to absolute paths to use the VFS, and then calling setCurrentWorkingDirectory on the VFS. This also changes the default VFS for `Driver` to use a virtualized working directory, instead of changing the process's working directory. Differential Revision: https://reviews.llvm.org/D62271 Modified: cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td cfe/trunk/lib/Driver/Driver.cpp cfe/trunk/lib/Driver/ToolChains/Clang.cpp cfe/trunk/test/Driver/working-directory.c Modified: cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td?rev=361885=361884=361885=diff == --- cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td (original) +++ cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td Tue May 28 15:21:47 2019 @@ -91,6 +91,8 @@ def err_no_external_assembler : Error< "there is no external assembler that can be used on this platform">; def err_drv_unable_to_remove_file : Error< "unable to remove file: %0">; +def err_drv_unable_to_set_working_directory : Error < + "unable to set working directory: %0">; def err_drv_command_failure : Error< "unable to execute command: %0">; def err_drv_invalid_darwin_version : Error< Modified: cfe/trunk/lib/Driver/Driver.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Driver.cpp?rev=361885=361884=361885=diff == --- cfe/trunk/lib/Driver/Driver.cpp (original) +++ cfe/trunk/lib/Driver/Driver.cpp Tue May 28 15:21:47 2019 @@ -133,7 +133,7 @@ Driver::Driver(StringRef ClangExecutable // Provide a sane fallback if no VFS is specified. if (!this->VFS) -this->VFS = llvm::vfs::getRealFileSystem(); +this->VFS = llvm::vfs::createPhysicalFileSystem().release(); Name = llvm::sys::path::filename(ClangExecutable); Dir = llvm::sys::path::parent_path(ClangExecutable); @@ -1005,6 +1005,11 @@ Compilation *Driver::BuildCompilation(Ar } } + // Check for working directory option before accessing any files + if (Arg *WD = Args.getLastArg(options::OPT_working_directory)) +if (std::error_code EC = VFS->setCurrentWorkingDirectory(WD->getValue())) + Diag(diag::err_drv_unable_to_set_working_directory) << WD->getValue(); + // FIXME: This stuff needs to go into the Compilation, not the driver. bool CCCPrintPhases; @@ -1984,20 +1989,11 @@ bool Driver::DiagnoseInputExistence(cons if (Value == "-") return true; - SmallString<64> Path(Value); - if (Arg *WorkDir = Args.getLastArg(options::OPT_working_directory)) { -if (!llvm::sys::path::is_absolute(Path)) { - SmallString<64> Directory(WorkDir->getValue()); - llvm::sys::path::append(Directory, Value); - Path.assign(Directory); -} - } - - if (getVFS().exists(Path)) + if (getVFS().exists(Value)) return true; if (IsCLMode()) { -if (!llvm::sys::path::is_absolute(Twine(Path)) && +if (!llvm::sys::path::is_absolute(Twine(Value)) && llvm::sys::Process::FindInEnvPath("LIB", Value)) return true; @@ -2023,12 +2019,12 @@ bool Driver::DiagnoseInputExistence(cons if (getOpts().findNearest(Value, Nearest, IncludedFlagsBitmask, ExcludedFlagsBitmask) <= 1) { Diag(clang::diag::err_drv_no_such_file_with_suggestion) - << Path << Nearest; + << Value << Nearest; return false; } } - Diag(clang::diag::err_drv_no_such_file) << Path; + Diag(clang::diag::err_drv_no_such_file) << Value; return false; } Modified: cfe/trunk/lib/Driver/ToolChains/Clang.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Clang.cpp?rev=361885=361884=361885=diff == --- cfe/trunk/lib/Driver/ToolChains/Clang.cpp (original) +++ cfe/trunk/lib/Driver/ToolChains/Clang.cpp Tue May 28 15:21:47 2019 @@ -616,11 +616,11 @@ static bool shouldUseLeafFramePointer(co } /// Add a CC1 option to specify the debug compilation directory. -static void addDebugCompDirArg(const ArgList , ArgStringList ) { - SmallString<128> cwd; - if (!llvm::sys::fs::current_path(cwd)) { +static void addDebugCompDirArg(const ArgList , ArgStringList , + const llvm::vfs::FileSystem ) {