[llvm] [LLVM] Fix VisualStudio detection (PR #212498)

Alexandre Ganea via llvm-commits llvm-commits at lists.llvm.org
Wed Sep 9 06:59:29 PDT 2026


================
@@ -675,6 +675,12 @@ bool llvm::findVCToolChainViaSetupConfig(
   ISetupInstancePtr NewestInstance;
   std::optional<uint64_t> NewestVersionNum;
   do {
+    bstr_t NameString;
+    HR = Instance->GetInstallationName(NameString.GetAddress());
+    if (FAILED(HR))
+      continue;
+    if (std::wstring_view(NameString).find(L"VisualStudio") != 0)
----------------
aganea wrote:

Use `starts_with` instead of `find`. Also please add `nullptr` guard for `NameString`. And please add a comment above to say why we're doing this, ie. "Ignore non-VS products registered with the VS Installer (e.g. SQL Server Management Studio), which have no VC toolchain."

https://github.com/llvm/llvm-project/pull/212498


More information about the llvm-commits mailing list