[clang] 9c195ba - [clang] Add include path for cppwinrt on Windows SDK 10.0.17134+

Hans Wennborg via cfe-commits cfe-commits at lists.llvm.org
Tue Jan 18 00:21:12 PST 2022


Author: Kagami Sascha Rosylight
Date: 2022-01-18T09:14:23+01:00
New Revision: 9c195bae31c4eefc3e5360cefb4f601388a4f6d9

URL: https://github.com/llvm/llvm-project/commit/9c195bae31c4eefc3e5360cefb4f601388a4f6d9
DIFF: https://github.com/llvm/llvm-project/commit/9c195bae31c4eefc3e5360cefb4f601388a4f6d9.diff

LOG: [clang] Add include path for cppwinrt on Windows SDK 10.0.17134+

This fixes https://github.com/llvm/llvm-project/issues/53112 by adding
cppwinrt to the include path when the SDK version is higher than
10.0.17134.0.

Differential revision: https://reviews.llvm.org/D117407

Added: 
    

Modified: 
    clang/lib/Driver/ToolChains/MSVC.cpp
    clang/test/Driver/cl-sysroot.cpp

Removed: 
    


################################################################################
diff  --git a/clang/lib/Driver/ToolChains/MSVC.cpp b/clang/lib/Driver/ToolChains/MSVC.cpp
index 66e9d8ab525a..4e15c3ab51ce 100644
--- a/clang/lib/Driver/ToolChains/MSVC.cpp
+++ b/clang/lib/Driver/ToolChains/MSVC.cpp
@@ -1333,6 +1333,15 @@ void MSVCToolChain::AddClangSystemIncludeArgs(const ArgList &DriverArgs,
         AddSystemIncludeWithSubfolder(DriverArgs, CC1Args, WindowsSDKDir,
                                       "Include", windowsSDKIncludeVersion,
                                       "winrt");
+        if (major >= 10) {
+          llvm::VersionTuple Tuple;
+          if (!Tuple.tryParse(windowsSDKIncludeVersion) &&
+              Tuple.getSubminor().getValueOr(0) >= 17134) {
+            AddSystemIncludeWithSubfolder(DriverArgs, CC1Args, WindowsSDKDir,
+                                          "Include", windowsSDKIncludeVersion,
+                                          "cppwinrt");
+          }
+        }
       } else {
         AddSystemIncludeWithSubfolder(DriverArgs, CC1Args, WindowsSDKDir,
                                       "Include");

diff  --git a/clang/test/Driver/cl-sysroot.cpp b/clang/test/Driver/cl-sysroot.cpp
index eb701f28514d..4db213a918a0 100644
--- a/clang/test/Driver/cl-sysroot.cpp
+++ b/clang/test/Driver/cl-sysroot.cpp
@@ -17,6 +17,7 @@
 // CHECK: "-internal-isystem" "[[ROOT]]{{/|\\\\}}Windows Kits{{/|\\\\}}10{{/|\\\\}}Include{{/|\\\\}}10.0.19041.0{{/|\\\\}}shared"
 // CHECK: "-internal-isystem" "[[ROOT]]{{/|\\\\}}Windows Kits{{/|\\\\}}10{{/|\\\\}}Include{{/|\\\\}}10.0.19041.0{{/|\\\\}}um"
 // CHECK: "-internal-isystem" "[[ROOT]]{{/|\\\\}}Windows Kits{{/|\\\\}}10{{/|\\\\}}Include{{/|\\\\}}10.0.19041.0{{/|\\\\}}winrt"
+// CHECK: "-internal-isystem" "[[ROOT]]{{/|\\\\}}Windows Kits{{/|\\\\}}10{{/|\\\\}}Include{{/|\\\\}}10.0.19041.0{{/|\\\\}}cppwinrt"
 
 // CHECK: "-libpath:[[ROOT]]{{/|\\\\}}DIA SDK{{/|\\\\}}lib{{/|\\\\}}amd64"
 // CHECK: "-libpath:[[ROOT]]{{/|\\\\}}VC{{/|\\\\}}Tools{{/|\\\\}}MSVC{{/|\\\\}}27.1828.18284{{/|\\\\}}lib{{/|\\\\}}x64"


        


More information about the cfe-commits mailing list