[llvm] Fix MSVC compile error in BitstreamRemarkParser.h when targeting C++17 (PR #163865)

Justin Holewinski via llvm-commits llvm-commits at lists.llvm.org
Thu Oct 16 14:11:46 PDT 2025


https://github.com/jholewinski created https://github.com/llvm/llvm-project/pull/163865

The following errors are seen in our builds using MSVC 2022:

BitstreamRemarkParser.h(115): error C2990: 'llvm::remarks::BitstreamBlockParserHelper': non-class template has already been declared as a class template
BitstreamRemarkParser.h(66): note: see declaration of 'llvm::remarks::BitstreamBlockParserHelper'

This change fixes the build issue by adding an explicit template argument to the `friend class` statements.

This issue is not seen if using `-std:c++20`, but we still support building as C++17.

>From 70234ede2ed6d90853563d1bf17f4e8ac6414c10 Mon Sep 17 00:00:00 2001
From: Justin Holewinski <jholewinski at nvidia.com>
Date: Thu, 9 Oct 2025 09:58:49 -0700
Subject: [PATCH] Fix MSVC compile error in BitstreamRemarkParser.h when
 targeting C++17

The following errors are seen in our builds using MSVC 2022:

BitstreamRemarkParser.h(115): error C2990: 'llvm::remarks::BitstreamBlockParserHelper': non-class template has already been declared as a class template
BitstreamRemarkParser.h(66): note: see declaration of 'llvm::remarks::BitstreamBlockParserHelper'

This change fixes the build issue by adding an explicit template
argument to the `friend class` statements.

This issue is not seen if using `-std:c++20`, but we still support
building as C++17.
---
 llvm/lib/Remarks/BitstreamRemarkParser.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/llvm/lib/Remarks/BitstreamRemarkParser.h b/llvm/lib/Remarks/BitstreamRemarkParser.h
index 4f66c47bb4b29..914edd8961290 100644
--- a/llvm/lib/Remarks/BitstreamRemarkParser.h
+++ b/llvm/lib/Remarks/BitstreamRemarkParser.h
@@ -112,7 +112,7 @@ class BitstreamBlockParserHelper : public BitstreamBlockParserHelperBase {
 /// Helper to parse a META_BLOCK for a bitstream remark container.
 class BitstreamMetaParserHelper
     : public BitstreamBlockParserHelper<BitstreamMetaParserHelper> {
-  friend class BitstreamBlockParserHelper;
+  friend class BitstreamBlockParserHelper<BitstreamMetaParserHelper>;
 
 public:
   struct ContainerInfo {
@@ -137,7 +137,7 @@ class BitstreamMetaParserHelper
 /// Helper to parse a REMARK_BLOCK for a bitstream remark container.
 class BitstreamRemarkParserHelper
     : public BitstreamBlockParserHelper<BitstreamRemarkParserHelper> {
-  friend class BitstreamBlockParserHelper;
+  friend class BitstreamBlockParserHelper<BitstreamRemarkParserHelper>;
 
 protected:
   SmallVector<uint64_t, 5> Record;



More information about the llvm-commits mailing list